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 Center および File ExchangePhysics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by