Scatter Plot Vectors of Different Lengths

33 visualizaciones (últimos 30 días)
Sclay748
Sclay748 el 13 de Ag. de 2020
Editada: Sclay748 el 13 de Ag. de 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!

Respuesta aceptada

Hayden Garmon
Hayden Garmon el 13 de Ag. de 2020
Editada: Hayden Garmon el 13 de Ag. de 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 comentario
Sclay748
Sclay748 el 13 de Ag. de 2020
Editada: Sclay748 el 13 de Ag. de 2020
It works. Thanks so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by