Plot only for positive y

6 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2018 年 6 月 12 日
コメント済み: Jack 2023 年 5 月 14 日
I have
plot(x,y)
hold on
plot(x,z)
hold on
plot(x,w)
I need to have a plot for only positive y and z. I try to write
ylim([0,yMax])
But I do not know how to set for yMax. Please advise.
  2 件のコメント
OCDER
OCDER 2018 年 6 月 12 日
編集済み: OCDER 2018 年 6 月 12 日
ylim([0,max(y)])
?
Curious, why do you have to plot(x, z) twice? Also, do you want to plot the maximum of y or z?
ylim([0, max([y(:); z(:)]))
alpedhuez
alpedhuez 2018 年 6 月 12 日
I have sought a simpler way to specify Y axis so that the figure only shows positive part of the Y-axis.

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

採用された回答

OCDER
OCDER 2018 年 6 月 12 日
編集済み: OCDER 2018 年 6 月 13 日
NEW ANSWER
ylim([0 inf]) %Will automatically compute the limit where "inf" is used
OLD ANSWER
ylim([0, max([y(:); z(:); w(:)]))
%will plot positive values of y axis from 0 to the maximum of either your y or z or w values.
  3 件のコメント
OCDER
OCDER 2018 年 6 月 13 日
Actually, there was an easier solution. I'll update the answer:
ylim([0 inf]) %will automatically compute the limit where "inf" is used
Jack
Jack 2023 年 5 月 14 日
this doesnt seem to work on my graph bit confused any ideas how I could be messing it up? im putting it after the plot(x,y) and have tried after title labels and after hold on so bit confused.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by