One approach would be ‘logical indexing’:
h = linspace(0,25);
T1 = 20 - h;
T2 = 10 + h;
Lv = abs(T2) > abs(T1);
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.
6 Comments
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079838
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079838
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079848
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079848
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079858
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079858
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079978
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079978
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079988
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1079988
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1084908
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/623083-how-to-show-the-plot-with-the-highest-value#comment_1084908
Sign in to comment.