1## s = boxplot_data (x) 2## 3## s.quantiles : quantiles [0.05, 0.25, 0.5, 0.75, 0.95] of x 4## s.outliers : 5function s = boxplot_data (x) 6 7C = columns (x); 8R = rows (x); 9 10if ! any (isnan (x(:))) 11 12 sx = sort (x); 13 14 ifloor = 1+floor([0.05 0.25 0.50 0.75 0.95]*(R-1)); 15 iceil = 1+ceil ([0.05 0.25 0.50 0.75 0.95]*(R-1)); 16 17 s.quantiles = (sx(ifloor,:) + sx(iceil,:))/2; 18 19 stdx = nanstd (x); 20 meanx = nanmean (x); 21 22 s.mean = meanx; 23 s.std = stdx; 24 25 for i = 1:C 26 iout = find (abs (x(:,i)-meanx(i)) > 3*stdx(i)); 27 s.outliers{i} = x(iout,i); 28 end 29else # There are NaNs 30 31 sx = sort (x); 32 33 nok = sum (!isnan (x)); 34 35 ifloor = 1+floor([0.05 0.25 0.50 0.75 0.95]'*(nok-1)); 36 iceil = 1+ceil ([0.05 0.25 0.50 0.75 0.95]'*(nok-1)); 37 38 s.quantiles = nan (5,C); 39 for i = 1:C 40 if nok(i) 41 s.quantiles(:,i) = (sx(ifloor(:,i),i)+sx(iceil(:,i),i))/2; 42 end 43 44 iout = find (abs (x(:,i)-meanx(i)) > 3*stdx(i)); 45 s.outliers{i} = x(iout,i); 46 end 47end 48