www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CreateNotchedBoxPlotsExample.m
%% Create Notched Box Plots % %% % Generate two sets of sample data. The first sample, |x1|, contains random % numbers generated from a normal distribution with |mu = 5| and |sigma = % 1|. The second sample, |x2|, contains random numbers generated from a % normal distribution with |mu = 6| and |sigma = 1|. rng default % For reproducibility x1 = normrnd(5,1,100,1); x2 = normrnd(6,1,100,1); %% % Create notched box plots of |x1| and |x2|. Label each box with its % corresponding |mu| value. figure boxplot([x1,x2],'Notch','on','Labels',{'mu = 5','mu = 6'}) title('Compare Random Data from Different Distributions') %% % The boxplot shows that the difference between the medians of the two % groups is approximately 1. Since the notches in the box plot do not % overlap, you can conclude, with 95% confidence, that the true medians do % differ. %% % The following figure shows the box plot for the same data with the % maximum whisker length specified as 1.0 times the interquartile range. % Data points beyond the whiskers are displayed using |+|. figure boxplot([x1,x2],'Notch','on','Labels',{'mu = 5','mu = 6'},'Whisker',1) title('Compare Random Data from Different Distributions') %% % With the smaller whiskers, |boxplot| displays more data points as outliers.