Having Boxplot problem with not defined double type

4 views (last 30 days)
Hello, I am trying to plot boxplot.
x = [1 2 3 4 5];
y = [1.13465 1.17166 1.19973 1.78338 1.83673
3.96e-12 3.6e-11 0.109991 1.0131 1.57166
0.574522 0.619429 0.685391 1.21099 1.73831
1.27e-11 0.142583 0.308049 0.890379 1.38142
3.5e-12 0.0606085 0.137094 0.565742 0.915032
1.77e-11 0.0206984 0.096124 0.213596 0.548369
0.343735 0.358206 0.386193 1.04343 1.80219
0.342868 0.333045 0.341806 0.760036 1.41684
0.423389 0.412866 0.415499 0.569211 0.564488
4e-12 3.67e-11 0.109991 1.0131 1.57166
0.692851 0.696025 0.704127 1.30321 1.88094
5.5e-11 0.0395349 0.180155 0.639514 1.04088];
boxplot(x,y)
this is the code that I used,
but when I tried to plot, it said
'The function 'boxplot' is not defined for inputs of type 'double'.
Error occurred: untitled (line 22) boxplot(x,y)'
Can anyone help me to solve the problem?
Thank you!

Answers (2)

Walter Roberson
Walter Roberson on 27 Jul 2024
You do not have the Statistics Toolbox installed or licensed.

Shashi Kiran
Shashi Kiran on 26 Jul 2024
To address the issue that you are facing with plotting boxplots in MATLAB, it is important to ensure your data is organized correctly. Given your requirement to plot only 5 boxplots without transposing the matrix, you need to make sure that each row in your data matrix represents a different group.
Below implementation is for your reference.
x=[1,2,3,4,5];
y = [
1.13465 1.17166 1.19973 1.78338 1.83673;
3.96e-12 3.6e-11 0.109991 1.0131 1.57166;
0.574522 0.619429 0.685391 1.21099 1.73831;
1.27e-11 0.142583 0.308049 0.890379 1.38142;
3.5e-12 0.0606085 0.137094 0.565742 0.915032;
1.77e-11 0.0206984 0.096124 0.213596 0.548369;
0.343735 0.358206 0.386193 1.04343 1.80219;
0.342868 0.333045 0.341806 0.760036 1.41684;
0.423389 0.412866 0.415499 0.569211 0.564488;
4e-12 3.67e-11 0.109991 1.0131 1.57166;
0.692851 0.696025 0.704127 1.30321 1.88094;
5.5e-11 0.0395349 0.180155 0.639514 1.04088
];
boxplot(y,x);
For further reference you can find the documentation of boxplot here: https://in.mathworks.com/help/stats/boxplot.html?s_tid=doc_ta#bu180jd-2

Community Treasure Hunt

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

Start Hunting!