I need help graphing boxplot

2 visualizaciones (últimos 30 días)
Journie Mayes
Journie Mayes el 11 de Abr. de 2020
Respondida: Cris LaPierre el 11 de Abr. de 2020
EXERCISE 5: Load the diaries.mat data of Lesson 10.
Define a variable called totalAlarm that holds the total number of times each subject in the cohort used the alarm.
I have tried TotalAlarm = nnz(useAlarm==1) and i get 2004. which is correct.
EXERCISE 6: Show boxplots of total alarm use by gender
Display figure similiar to EXAMPLE 3 with box plots of total alarm use broken down by gender.
This is the format of example 3.
figure
boxplot(sepalLens, species) % The species vector specifies the group
ylabel('Sepal length in mm')
title('Comparison of three species in the Fisher iris data')
  • I have tried TotalAlarm = nnz(useAlarm==1); to find the number of times and it gave me 2004. But when i try to make a box plot that is totalAlarm by gender, it gives me error.
gender is 144x1
total Alarm is 2004
How do i make a boxplot using the format above?
  2 comentarios
darova
darova el 11 de Abr. de 2020
I think is too complicated. Can you make a sketch of the result you want to achieve?
dpb
dpb el 11 de Abr. de 2020
So, show us the variables you started with and have created via
whos useAlarm ...
where the ... asks for which other variables are availble in the list as well and also show the code you use to try to do the box plot. We can't diagnose what we can't see and we can't see your terminal from here...

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 11 de Abr. de 2020
What is the raw source of your data? A table?
Right now, there is no connection between TotalAlarm and gender. Ideally, this is a matrix with the data in one column, and the group value in the second. When your data has different length vectors, boxplot has no way of knowing what group each of your data values belongs to.
I suspect your raw data contains this information? Use this index then to extract the rows of alarms and gender variables.
idx = useAlarm==1;
boxplot(plotValues(idx),groupValues(idx))

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by