Boxplot and Dimensions Arrays

12 ビュー (過去 30 日間)
Saira Ahmed
Saira Ahmed 2019 年 3 月 22 日
コメント済み: Saira Ahmed 2019 年 3 月 22 日
%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]';
  1 件のコメント
Saira Ahmed
Saira Ahmed 2019 年 3 月 22 日
That worked perfectly, thank you!

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by