Plotting a portion of a graph

If i have a vector of 200 values and I want to plot the values between 50 and 70, how to do so?

回答 (2 件)

Image Analyst
Image Analyst 2015 年 3 月 27 日

2 投票

Very ambiguous so I guess I'll have to answer several potential cases.
To plot indexes between 50 and 70:
plot(vector(50:70), 'b*-');
To plot values of vector between 50 and 70 (i.e. the y values rather than the indexes):
indexesInRange = vector >= 50 & vector <= 70;
subVector = vector(indexesInRange);
plot(subVector, 'b*-');
If you have another vector x that is different than the indexes, for example you have a 100 indexes but x ranges from 0 to 5000, then
indexesInRange = x >= 50 & x <= 70;
subVector = vector(indexesInRange);
plot(subVector, 'b*-');

2 件のコメント

Amira Akra
Amira Akra 2015 年 3 月 27 日
@Image Analyst, thank you, I mean the second case you mentioned i.e. (To plot values of vector between 50 and 70).
Image Analyst
Image Analyst 2015 年 3 月 27 日
You're welcome. If we're done then could you mark the Answer as "Accepted"?

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

Thorsten
Thorsten 2015 年 3 月 27 日

0 投票

plot(vector(50:70))

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

タグ

質問済み:

2015 年 3 月 27 日

コメント済み:

2015 年 3 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by