# Scatter Plot Vectors of Different Lengths

18 views (last 30 days)
Sclay748 on 13 Aug 2020
Edited: Sclay748 on 13 Aug 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!

Hayden Garmon on 13 Aug 2020
Edited: Hayden Garmon on 13 Aug 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])
Sclay748 on 13 Aug 2020
Edited: Sclay748 on 13 Aug 2020
It works. Thanks so much!

### Categories

Find more on Scatter Plots in Help Center and File Exchange

R2020a

### Community Treasure Hunt

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

Start Hunting!