How to do boxplot for vectors with differents lenghts?

1 Ansicht (letzte 30 Tage)
pink flower
pink flower am 3 Dez. 2020
Kommentiert: pink flower am 3 Dez. 2020
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!

Antworten (1)

Cris LaPierre
Cris LaPierre am 3 Dez. 2020
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));

Community Treasure Hunt

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

Start Hunting!

Translated by