How to show the plot with the highest value?

Hey! How am I supposed to only show the plot with the highest values for h. The graph should show the plot with abs(T1) first and then change to abs(T2) when they intersect and abs(T2) get higher than abs(T1). With the following code I get both plots in all values
plot(h,abs(T1),'b')
hold on
plot(h,abs(T2),'g')
Thanks!

6 件のコメント

Star Strider
Star Strider 2020 年 10 月 22 日
We will not ask for it to be deleted.
We will instead ask for it to be restored.
Randomdude123
Randomdude123 2020 年 10 月 22 日
So there is no way to get it removed? Since I used the wrong account and I don't want my name shown with this.
Star Strider
Star Strider 2020 年 10 月 22 日
You can possibly change your account name with this account, however deleting Questions with appropriate Answers is not something we endorse, much less allow here. You can take it up with the appropriate people in MathWorks if you so desire.
We are neither being unfriendly nor obstinate. This is a open forum, and Questions and Answers are available to all who want to read them. It is important for the integrity of the forum.
Rik
Rik 2020 年 10 月 22 日
編集済み: Walter Roberson 2020 年 10 月 25 日
Question originally posted by [User], restored from Google cache (I included the name in case this is an attempt to avoid cheat detection, if someone with editing privileges disagrees, feel free to remove the name and this remark from my comment):
How to show the plot with the highest value?
Hey! How am I supposed to only show the plot with the highest values for h. The graph should show the plot with abs(T1) first and then change to abs(T2) when they intersect and abs(T2) get higher than abs(T1). With the following code I get both plots in all values
plot(h,abs(T1),'b')
hold on
plot(h,abs(T2),'g')
Thanks!
Star Strider
Star Strider 2020 年 10 月 22 日
Rik — Thank you!
Walter Roberson
Walter Roberson 2020 年 10 月 25 日
(Mathworks says we have to remove names upon request. Legal reasons, I guess.)

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

 採用された回答

Star Strider
Star Strider 2020 年 10 月 22 日

0 投票

One approach would be ‘logical indexing’:
h = linspace(0,25);
T1 = 20 - h;
T2 = 10 + h;
Lv = abs(T2) > abs(T1); % Logical Index Vector
figure
plot(h,abs(T1),'b', 'LineWidth',2)
hold on
plot(h,abs(T2),'g', 'LineWidth',2)
plot(h(~(Lv)),abs(T1(~Lv)), '--r', 'LineWidth',1.0)
plot(h(Lv),abs(T2(Lv)), '--r', 'LineWidth',1.0)
hold off
Experiment to get the result you want.

その他の回答 (1 件)

the cyclist
the cyclist 2020 年 10 月 22 日

0 投票

plot(h,max(abs(T1),abs(T2)))

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by