Hi, I’m computing some statistical values from a dataset (z). I’ll repeat this code for 7 more datasets and I would like that all statistical values are displayed in a table for my 8 datasets as follow:
std var mean ...z1z2z3...
For the moment, my code look like this and only displays the data in the command window. Thanks for your help!
load C1_Z1
z = C1_Z1(:,3);
%%%%%% STATISTICS
% number of observations
Nz = size(z);
% compute mean
mz = mean(z);
% compute the standard deviation
sigma = std(z);
% compute the median
medianz = median(z);
% compute variance
variance_z = var(z);
% compute skewness
coef_skew = skewness(z);
%compute max value
MaxValue = max(z);
% compute min value
MinValue = min(z);
% STEP 1 – rank the data
a = sort(z);
% compute 25th percentile (first quartile)
Q(1) = median(a(find(a<median(a))));
% compute 50th percentile (second quartile)
Q(2) = median(a);
% compute 75th percentile (third quartile)
Q(3) = median(a(find(a>median(a))));
% compute Interquartile Range (IQR)
IQR = Q(3)-Q(1);
% determine extreme Q1 outliers (e.g., x < Q1 – 3*IQR)
ia = find(a<Q(1)-3*IQR);
if length(ia)>0,
outliersQ1 = a(ia);else outliersQ1 = [];end
% determine extreme Q3 outliers (e.g., x > Q1 + 3*IQR)
ia = find(a>Q(1)+3*IQR);
if length(ia)>0,
outliersQ3 = a(ia);else outliersQ3 = [];end
% compute total number of outliers
Noutliers = length(outliersQ1)+length(outliersQ3);
% display results
disp(['Mamimum Value:',num2str(MaxValue)]);
disp(['Minimum Value:',num2str(MinValue)]);
disp(['Number of Observations:',num2str(Nz)]);
disp(['Mean: ',num2str(mz)]);
disp(['Standard Deviation: ',num2str(sigma)]);
disp(['Variance: ',num2str(variance_z)]);
disp(['Coefficient of Skewness: ',num2str(coef_skew)]);
disp(['Median: ',num2str(medianz)]);
disp(['25th Percentile: ',num2str(Q(1))]);
disp(['50th Percentile: ',num2str(Q(2))]);
disp(['75th Percentile: ',num2str(Q(3))]);
% disp(['Semi Interquartile Deviation: ',num2str(SID)]);
disp(['Number of outliers: ',num2str(Noutliers)]);
%%%Creation of a uitable
t = uitable;
set(t,'ColumnWidth',{25})
cnames = {'Mean','Median','STD', '…’};
rnames = {'z1','z2','z3', '…', 'z8’};
t = uitable('ColumnName',cnames,'RowName',rnames);
Best Answer