フィルターのクリア

How can I hide a part of my function?

4 ビュー (過去 30 日間)
Mo_B
Mo_B 2017 年 1 月 17 日
コメント済み: Mo_B 2017 年 1 月 17 日
Hi guys,
i want to hide some parts of three functions, shown in the attachement
The red line should stay as it is, but the other three should stop displaying after x=60
x=(0:0.01:70).';
y1=(0.02049/0.4)*x;
y2=(0.3*60./(1+(1.331./(sqrt(0.0631*x./(60-x))).^3)));
y3=(0.3*60./(1+(1.331./(sqrt(0.0631*x./(60-x))).^3)))-(0.02049/0.4)*x;
y4=(0.02049/0.4)*x-(0.3*60./(1+(1.331./(sqrt(0.0631*x./(60-x))).^3)));
plot(x,y1,'r','LineWidth',3)
hold on
plot(x,y2,'Color',[0.9 0.5 0],'LineWidth',3)
plot(x,y3,'Color',[0 0.5 0],'LineWidth',3)
plot(x,y4,'k','LineWidth',3)
axis([0 70 0 4])
thank you very much!

採用された回答

Stephen23
Stephen23 2017 年 1 月 17 日
編集済み: Stephen23 2017 年 1 月 17 日
NaN values are not plotted, so you can simply replace any values that you do not want to see with NaN:
x=(0:0.01:70).';
y1=(0.02049/0.4)*x;
y2=(0.3*60./(1+(1.331./(sqrt(0.0631*x./(60-x))).^3)));
y3=(0.3*60./(1+(1.331./(sqrt(0.0631*x./(60-x))).^3)))-(0.02049/0.4)*x;
y4=(0.02049/0.4)*x-(0.3*60./(1+(1.331./(sqrt(0.0631*x./(60-x))).^3)));
% new code here:
idx = x>60;
y2(idx) = NaN;
y3(idx) = NaN;
y4(idx) = NaN;
% new code ends
plot(x,y1,'r','LineWidth',3)
hold on
plot(x,y2,'Color',[0.9 0.5 0],'LineWidth',3)
plot(x,y3,'Color',[0 0.5 0],'LineWidth',3)
plot(x,y4,'k','LineWidth',3)
axis([0 70 0 4])
  1 件のコメント
Mo_B
Mo_B 2017 年 1 月 17 日
thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by