フィルターのクリア

Scatter Plot Vectors of Different Lengths

15 ビュー (過去 30 日間)
Sclay748
Sclay748 2020 年 8 月 13 日
編集済み: Sclay748 2020 年 8 月 13 日
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
Hayden Garmon 2020 年 8 月 13 日
編集済み: Hayden Garmon 2020 年 8 月 13 日
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 件のコメント
Sclay748
Sclay748 2020 年 8 月 13 日
編集済み: Sclay748 2020 年 8 月 13 日
It works. Thanks so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by