How to find the intersection points on two functions
2 views (last 30 days)
Show older comments
how to find the intersection points of dH_rem and dH_gen within the limits specified below
To=500:1:850; %outlet temp
Ti=570; %inlet temp
y_A=0.003; %proportion of benzene in feed
V=8.5;
P=3e5; %Pa
R=8.3145; %kJ/mol.K
Cp=1.09 %kJ/kgK
Mr_air=29e-3; %kg/mol
dH_1=-1850; %kJ/mol
dH_2=-1423;
dH_3=-3273;
F_ao=0.1; %molar flow rate of benzene
k1 = 1e7.*exp(-12700./To);
k2 = 5e4.*exp(-10800./To);
k3 = 7e7.*exp(-15000./To);
t=(V.*y_A.*P)./(F_ao.*R.*To);
X=(t.*(k1+k3))./(1+t.*(k1+k3));
S=k1./((1+(k2.*t)).*(k1+k3));
Y_B = (k1.*t)./(((k2.*t)+1).*(1+(t.*(k1+k3))));
dH_gen=-((V.*y_A.*P)./(R.*To)).*((((k1.*dH_1)+(k3.*dH_3)).*(1-X))+(k2.*X.*S.*dH_2));
plot(To,dH_gen)
hold on
dH_rem=(Mr_air./y_A).*F_ao.*Cp.*(To-Ti);
plot(To,dH_rem)
hold off
0 Comments
Answers (1)
John D'Errico
on 4 Feb 2018
Standard question: how to find the intersection(s) of two functions.
1. Subtract them. Where the difference is zero, there lies an intersection.
2. Use a root finder. That could be anything from fzero, solve, vpasolve, fsolve, etc.
Note that all standard optimization based root finders will find ONE root, and only one root. It will depend on your starting values. Solve might be able to find the three points of intersection I saw on the plot.
The lazy solution to finding an approximate root is to use a tool like Doug Schwarz's intersections code on the FEX. Evaluate each function at a few hundred points, then call intersections. It will use linear interpolation to find the crossing points. But a virtue of that solution is it will report all crossings between the curves.
4 Comments
Walter Roberson
on 4 Feb 2018
When I use the code you posted, except replacing that assignment with syms To, then dH_rem = (3161*To)/3000 - 60059/100 which is linear with the single solution To == 570. Perhaps you are using different code by now?
See Also
Categories
Find more on Assumptions 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!