boxplot with vectors of different lengths???

4 次查看(过去 30 天)
Ern V
Ern V 2016-10-14
回答: KSSV 2016-10-14
Hi, i know that this is not the first time that this question is being asked, but i want to know if there is an alternative way to do this. The answers that i found is
>> c_1=rand(1,20);
>> c_2=rand(1,100);
>> C = [c_1 c_2];
>> grp = [zeros(1,20),ones(1,100)];
>> boxplot(C,grp)
But i dont find this one very practical, because if you have large number of vectors, with different lengths, you have to do
grp = [zeros(1,n1),ones(1,n2), 2*ones(1,n3), 3*ones(1,n4),...]
So how can i do the boxplot with multiple vectors with different lengths? Thank you

回答(1 个)

KSSV
KSSV 2016-10-14
clc; clear all ;
S = [] ; grp =[] ;
for i = 1:20
C = rand(randsample(1:100,1),1) ;
S = [S ; C] ;
grp = [grp ; i*ones(size(C))] ;
end
boxplot(S,grp)

类别

Help CenterFile Exchange 中查找有关 Physics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by