boxplot with vectors of different lengths???

4 visualizzazioni (ultimi 30 giorni)
Ern V
Ern V il 14 Ott 2016
Risposto: KSSV il 14 Ott 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

Risposte (1)

KSSV
KSSV il 14 Ott 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)

Categorie

Scopri di più su Physics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by