How to efficiently plot functions?

2 ビュー (過去 30 日間)
Ashton Linney
Ashton Linney 2020 年 3 月 25 日
コメント済み: Ashton Linney 2020 年 3 月 25 日
I have 12 curves I need to plot on a single graph. This is the current script I have where I have manually asked it to plot each curve.
plot(t,y(:,1),t,y(:,2),t,y(:,3),t,y(:,4),t,y(:,5),t,y(:,6),t,y(:,7),t,y(:,8),t,y(:,9),t,y(:,10),t,y(:,11),t,y(:,12))
Is there a way to make this more efficient without having to write out for each 12?

採用された回答

John D'Errico
John D'Errico 2020 年 3 月 25 日
編集済み: John D'Errico 2020 年 3 月 25 日
Wyhy not try it? I don't have t or y, so I'll make them up.
t = (1:10)';
y = rand(10,12);
plot(t,y)
Actually, I don't need to transpose t there, making it a column vector. It just makes me feel better to do so.
  1 件のコメント
Ashton Linney
Ashton Linney 2020 年 3 月 25 日
Perfect, thank you!

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

その他の回答 (1 件)

Peng Li
Peng Li 2020 年 3 月 25 日
If t is a vector, you use
plot(t, y);
that will automatically plot each column of y against vector t.
  1 件のコメント
Ashton Linney
Ashton Linney 2020 年 3 月 25 日
Perfect, thank you!

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by