Effacer les filtres
Effacer les filtres

How can I connect the maximum points of several

4 vues (au cours des 30 derniers jours)
Xerxes Achaemenid
Xerxes Achaemenid le 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 commentaires
darova
darova le 13 Mar 2021
Can you attach the data?
Xerxes Achaemenid
Xerxes Achaemenid le 13 Mar 2021
clear
clc
t=263:0.001:383;
for r=0.001:0.001:0.005
[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
for r=0.01:0.01:0.05
[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')
grid on
hold on
end
for r=0.1:0.1:0.5
[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')
grid on
hold on
end
for r=1:1:5
[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')
grid on
hold on
end
text(268,0.8998,' -rA=0.001','FontSize',8, 'color','b'); text(273,0.8659,' -rA=0.002','FontSize',8, 'color','r');
text(274,0.7989,' -rA=0.003','FontSize',8, 'color','0.75, 0.75, 0'); text(278,0.7724,' -rA=0.005','FontSize',8, 'color','m')
text(283,0.6867,' -rA=0.01','FontSize',8, 'color','g'); text(288,0.5631,' -rA=0.02','FontSize',8, 'color','b')
text(293,0.5372,' -rA=0.03','FontSize',8, 'color','r'); text(298,0.449,' -rA=0.05','FontSize',8, 'color','b')
text(308,0.4172,' -rA=0.1','FontSize',8, 'color','r'); text(318,0.3568,' -rA=0.2','FontSize',8, 'color','0.75, 0.75, 0')
text(323,0.2748,' -rA=0.3','FontSize',8, 'color','m'); text(333,0.2865,' -rA=0.5','FontSize',8, 'color','g')
text(348,0.2818,' -rA=1','FontSize',8, 'color','b'); text(363,0.2034,' -rA=2','FontSize',8, 'color','r')
text(368,0.1101,' -rA=3','FontSize',8, 'color','r'); text(378,0.05138,' -rA=5','FontSize',8, 'color','y')
%x=[383 378 373 358 353 348 343 333 328 328 323 318 313 308 308 303];
%y=[0.0819 0.1618 0.2348 0.3886 0.5422 0.64 0.7088 0.7976 0.8636 0.8980 0.9203 0.9471 0.9650 0.9740 0.9797 0.9867];
%line(x,y,'color','k')
hold off

Connectez-vous pour commenter.

Réponse acceptée

darova
darova le 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 commentaires
darova
darova le 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])
Xerxes Achaemenid
Xerxes Achaemenid le 13 Mar 2021
It's wonderful, This is what I wanted, smart way...Thank you very much

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by