Boxplot with multiple figures

I cannot get this code to work. Both HAL and one2three are a 22x1 array. I need to put them on a boxplot but cannot get it to work. The group part was just added but nothing is coming out with that either. They are both the same length and I keep getting an error message.
HAL = Project1Data(2:23,1);
one2three = Project1Data(2:23,2);
group = [ones(size(HAL)); 2*ones(size(one2three))];
boxplot([HAL, one2three],group);
title("Lotus Scores");
xlabel("Lotus Group");
ylabel("Score (0-10)");
I added the data below, titled Project_1_Data.

 Risposta accettata

Adam Danz
Adam Danz il 27 Ott 2020
Modificato: Adam Danz il 27 Ott 2020
Turn the first input into a vector,
boxplot([HAL; one2three],group);
% ^
or use a matrix without a grouping variable,
HAL = Project1Data(2:23,1);
one2three = Project1Data(2:23,2);
boxplot([HAL, one2three]);

2 Commenti

Alejandro Jimenez
Alejandro Jimenez il 27 Ott 2020
Modificato: Adam Danz il 27 Ott 2020
Not using the grouping variable leads to this
Error using boxplot>straightenX (line 898)
'X' parameter must be a numeric vector or matrix.
Error in boxplot (line 274)
[xDat,gDat,origRow,xlen,gexplicit,origInd,origNumXCols] =
straightenX(x,g);
Error in Project_1 (line 4)
boxplot([HAL, one2three]);
Adam Danz
Adam Danz il 27 Ott 2020
Modificato: Adam Danz il 27 Ott 2020
So, what is X if it's not a vector or matrix?
The first two lines below indicate that HAL and one2three are column vectors of equal length.
The third line horizontally concatenates those two column vectors to make a matrix.
HAL = Project1Data(2:23,1);
one2three = Project1Data(2:23,2);
boxplot([HAL, one2three]);
If that's not the case for your data, provide more info on the inputs you're using to boxplot.

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by