How can I connect the maximum points of several
2 views (last 30 days)
Show older comments
Xerxes Achaemenid
on 13 Mar 2021
Commented: Xerxes Achaemenid
on 13 Mar 2021
Hello friends, I want to connect the maximum points of several graphs with a curved line in one figure. I can calculate the coordinates of maximum points then connect them with a line, But I want a code that Matlab itself recognizes the maximum points and connects them. Thanks for your attention
2 Comments
Accepted Answer
darova
on 13 Mar 2021
THe short version
clear
clc
t=263:1:383;
rr = 1:5;
for r = [ rr/1000 rr/100 rr/10 rr ]
[T, R]=meshgrid(t,r);
k1=exp(17.34-(48900./(8.314*T)));
k2=exp(42.02-(124200./(8.314*T)));
XA=(k1-R)./(k1+k2);
[XA_max, index] = max(XA);
T_max = T(index);
plot(T, XA, T_max, XA_max, 'ro')
axis([263,383,0,1])
grid on
hold on
end
hold off
3 Comments
darova
on 13 Mar 2021
Another interpretation
clear
clc
cla
t = linspace(263,383,30);
rr = 1:5;
r = [ rr/1000 rr/100 rr/10 rr ];
[T, R]=meshgrid(t,r);
k1=exp(17.34-(48900./(8.314*T)));
k2=exp(42.02-(124200./(8.314*T)));
XA=(k1-R)./(k1+k2);
[~, index] = max(XA,[],2);
ind = sub2ind(size(XA),1:size(XA,1),index(:)');
plot(T(ind), XA(ind), 'r-o')
line(T',XA')
text(T(ind), XA(ind),num2str(XA(ind)'))
ylim([0 1])
More Answers (0)
See Also
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!