How can I create a plot for 2 different groups?

15 vues (au cours des 30 derniers jours)
Sarah Appenzeller
Sarah Appenzeller le 15 Nov 2019
I have a dataset with two groups id_group (young = 1, old = 2) in an xlsx format.
They did a training study of 20 sessions where I have for each person 1 value per session.
How can I now create a plot showing the course of the results over the 20 sessions for the young group and the old group in the same plot?
These are the means of the results for all participants:
y = [x_training_num_1,x_training_num_2, x_training_num_3, x_training_num_4,x_training_num_5, x_training_num_6, x_training_num_7, x_training_num_8, x_training_num_9, x_training_num_10, x_training_num_11, x_training_num_12, x_training_num_13, x_training_num_14,x_training_num_15, x_training_num_16, x_training_num_17, x_training_num_18, x_training_num_19, x_training_num_20];
then I tried to find the groups:
g = findgroups(id_group);
and I tried to plot it:
plot(y,'group','id_group')
but then this error occurs:
Error using plot
There is no group property on the Line class.
Error in behavioralscript (line 33)
plot(y,'group','id_group')
Thanks for your help!

Réponses (1)

Siriniharika Katukam
Siriniharika Katukam le 18 Nov 2019
Hi
As per my understanding, you are trying to plot the two groups that are differentiated by the line
g = findgroups(id_group);
the doubt is why are you not passing “y” as an argument to findgroups.
Moreover in the line
plot(y,'group','id_group')
plot takes the group in quotes as a input argument and shows up the error that you have got. Using the function plot can be understood from the following page:
Correct me if I misunderstood y and id_group.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by