Issue plotting boxplot using data from data frame

9 ビュー (過去 30 日間)
ey21
ey21 2021 年 2 月 5 日
回答済み: Anmol Dhiman 2021 年 2 月 11 日
Hello all,
I have a dataframe 'Newdata'.
I want to create a boxplot with 5 categories of the independent variable 'Religiosity' and the continous dependent variable 'Spatial Memory'. Thus, there should be five boxplots overall, one for each category of the independent variable 'religiosity'.
I have tried using the boxplot function - boxplot(Newdata, 'whisker',1.5) but this is giving me the error:
'X' parameter must be a numeric vector or matrix.
Would anyone be able to give me a helping hand as to how I can do this using the dataframe I have?
I have attached a screenshot below.
Thanks!

採用された回答

Anmol Dhiman
Anmol Dhiman 2021 年 2 月 11 日
Hi Emre,
You are getting the error as NewData variable is a cell array whereas boxplot requires it to be a matrix.
To resolve the error you need to convert the cell array to matrix.
I would suggest you to first extract the indices of individual types using this answer.
After the extraction, get the respective values and store in a matrix.
Then you can call the boxplot.
Hope it helps

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by