If I have an array that is size 2x60, how do I plot row 2 vs. row 1?

3 ビュー (過去 30 日間)
Anna Blakley
Anna Blakley 2016 年 10 月 12 日
回答済み: Image Analyst 2016 年 10 月 12 日
Would it be plot(data(2,:),data(1,:))?

採用された回答

Star Strider
Star Strider 2016 年 10 月 12 日
編集済み: Star Strider 2016 年 10 月 12 日
Would it be
plot(data(2,:),data(1,:))
Yes if you want row 2 as the x (independent) variable and row 1 as the y (dependent) variable. Otherwise, reverse them.
  2 件のコメント
Anna Blakley
Anna Blakley 2016 年 10 月 12 日
Thank you so much!
Star Strider
Star Strider 2016 年 10 月 12 日
My pleasure!

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2016 年 10 月 12 日
No. You reversed them. For example if you say you want to plot the "signal vs. time" or "y vs. x" or "weight vs. height, the vertical/dependent variable comes first in the verbal description, but second in the call to plot(). The horizontal/independent variable comes second in the verbal description, but first in the call to plot().
So if you want to plot y vs. x, it would be plot(x, y), NOT plot(y, x).
Plotting vec1 vs. vec2 would be plot(vec2, vec1), not plot(vec1, vec2).
So in your example plotting row 2 vs. row 1 would be plot(data(1,:),data(2,:)), not plot(data(2,:),data(1,:)) as you had it. This will plot row 2 as a function of row 1, which is what you asked. Your code would plot row 1 as a function of row 2, which is the opposite of what you asked.

カテゴリ

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