Effacer les filtres
Effacer les filtres

Scatter Plot Vectors of Different Lengths

15 vues (au cours des 30 derniers jours)
Sclay748
Sclay748 le 13 Août 2020
Modifié(e) : Sclay748 le 13 Août 2020
Hello, I am trying to make a scatterplot for some data. The data is a bit more complicated and large, so I have recreated a sample below on a smaller level for the sake of understanding what I am trying to do.
I have 3 experiments that each have data from 4-6 trials. I get an error that the vector size must be the same when I use the scatter function.
Example:
Experiment 1 Data (in seconds) [ 33, 43, 45, 34]
Experiment 2 Data (in seconds) [ 44, 47, 43, 48, 49, 46]
Experiment 3 Data (in seconds) [ 54, 47, 56, 57, 49]
I want the X axis to show Experiment 1, 2, 3 and the Y axis to show time with the points scattered based on their time in seconds while staying within their respective experiment group on the x axis.
Thanks!

Réponse acceptée

Hayden Garmon
Hayden Garmon le 13 Août 2020
Modifié(e) : Hayden Garmon le 13 Août 2020
Does this work?
vec1= [ 33, 43, 45, 34];
vec2= [ 44, 47, 43, 48, 49, 46];
vec3= [ 54, 47, 56, 57, 49] ;
plot(ones(1,length(vec1)),vec1,'x')
hold on
plot(2*ones(1,length(vec2)),vec2,'o')
plot(3*ones(1,length(vec3)),vec3,'*')
legend('Exp 1','Exp 2','Exp 3')
xlim([-1,5])
  1 commentaire
Sclay748
Sclay748 le 13 Août 2020
Modifié(e) : Sclay748 le 13 Août 2020
It works. Thanks so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Discrete Data 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