Boxplot and Dimensions Arrays

11 Ansichten (letzte 30 Tage)
Saira Ahmed
Saira Ahmed am 22 Mär. 2019
Kommentiert: Saira Ahmed am 22 Mär. 2019
%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?

Akzeptierte Antwort

the cyclist
the cyclist am 22 Mär. 2019
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]';
  1 Kommentar
Saira Ahmed
Saira Ahmed am 22 Mär. 2019
That worked perfectly, thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by