How to do boxplot for vectors with differents lenghts?

1 回表示 (過去 30 日間)
pink flower
pink flower 2020 年 12 月 3 日
コメント済み: pink flower 2020 年 12 月 3 日
Hello everyone.
I have 3 files with 1 vector each, and each vector has a different size. File 1 has a vector with 12646482 lines. File 2 has 14486045 and file 3 has 108052. I tried to do this:
clear all;
close all;
bb = load('/home/Documents/file1.txt');
mm = load('/home/Documents/file2.txt');
aa = load('/home/Documents/file3.txt');
x1 = rand(12646482,1);
x2 = rand(14486045,1);
x3 = rand(108052,1);
x = [x1;x2;x3];
nn = [bb; mm; aa];
boxplot(x, nn);
But I did not succeed. How can I solve this? Thank you!

回答 (1 件)

Cris LaPierre
Cris LaPierre 2020 年 12 月 3 日
How many boxplots would you like to see? I assume one for each file.
Use the documentation to help you get the syntax right. This example should help as well. Note that the grouping data is the second input, not the first.
I'd modify your code as follows
bb = load('/home/Documents/file1.txt');
mm = load('/home/Documents/file2.txt');
aa = load('/home/Documents/file3.txt');
% I'm assuming your data is a column vector
bb(:,2) = 1;
mm(:,2) = 2;
aa(:,2) = 3;
nn = [bb; mm; aa];
boxplot(nn(:,1),nn(:,2));
  1 件のコメント
pink flower
pink flower 2020 年 12 月 3 日
I just want a boxplot with three boxes.

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

Community Treasure Hunt

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

Start Hunting!

Translated by