Boxplot and Dimensions Arrays

10 次查看(过去 30 天)
%msf for sample size
msfs = [0.8929, 0.8547, 0.998, 0.9506, 0.9074, 0.9074];
%msf for population
msfp = [0.9836, 0.9685, 0.9097, 0.9027, 0.8278, 0.7551, 0.8929, 0.8547, 0.998, 0.9506, 0.9074, 0.9074, 1.0291, 1.032, 1.1996, 1.1181, 0.939, 0.752, 0.762, 0.0253, 0.933, 1.073, 0.644, 0.789];
%boxplot
figure(8)
group = [ ones(size(msfs)); 2*ones(size(msfp)) ];
boxplot([msfs; msfp], group)
set(gca, 'XTixkLabel', {'group', 'population'})
So, I'm trying to plot two vectors as a boxplot side by side and I've used the above code. But when input into MATLAB I get the following error message:
Dimensions of arrays being concatenated are not consistent.
And I wasn't sure how to fix it, I was wondering if anyone would be able to help?

采纳的回答

the cyclist
the cyclist 2019-3-22
If you define your original arrays as column vectors, instead of row vectors, your code will work. Try this instead:
%msf for sample size
msfs = [0.8929, 0.8547, 0.998, 0.9506, 0.9074, 0.9074]';
%msf for population
msfp = [0.9836, 0.9685, 0.9097, 0.9027, 0.8278, 0.7551, 0.8929, 0.8547, 0.998, 0.9506, 0.9074, 0.9074, 1.0291, 1.032, 1.1996, 1.1181, 0.939, 0.752, 0.762, 0.0253, 0.933, 1.073, 0.644, 0.789]';

更多回答(0 个)

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by