boxplot with vectors of different lengths???

4 Ansichten (letzte 30 Tage)
Ern V
Ern V am 14 Okt. 2016
Beantwortet: KSSV am 14 Okt. 2016
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

Antworten (1)

KSSV
KSSV am 14 Okt. 2016
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)

Kategorien

Mehr zu Physics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by