How to solve this system of nonlinear equations?

4 visualizzazioni (ultimi 30 giorni)
So I have got this equation over here (if you need it I will write it below) where I know all the constants except x2L and T. I have to give values from 0 to 100 to x2L and solve T for each value of x2L so I can find T(x2L). I have to solve the ecuation numerically and I just dont know how. Here's what I tried with some help so far, and didnt make it yet. Hope you guys can help me:
%Constants:
HVAP1 = 41400; HVAP2 = 38800;
TVAP1 = 99.974+273.15; TVAP2 = 78.32+273.15;
B =0.239424218
OMEGA = 3513.545297
R = 8.314472;
%The function
Function = exp(OMEGA./(R.*T).*(1+3*B-4*B.*X2L).*X2L.^2+HVAP1/R.*(1/TVAP1-1./T)).*(1-X2L)+exp(OMEGA./(R.*T)*(1+B-4*B*X2L).*(1-X2L).^2+HVAP2/R.*(1/TVAP2-1./T)).*X2L-1;
%What I tried
syms X2L T
Function = exp(OMEGA./(R.*T).*(1+3*B-4*B.*X2L).*X2L.^2+HVAP1/R.*(1/TVAP1-1./T)).*(1-X2L)+exp(OMEGA./(R.*T)*(1+B-4*B*X2L).*(1-X2L).^2+HVAP2/R.*(1/TVAP2-1./T)).*X2L-1;
X2L = 0:0.1:100;
eqns=subs(Funcion,X2L);
TL=solve(eqns,T)
When I try to use this matlab sents me the message "Empty sym: 0-by-1" whice I've read it usually means there is no possible answer to this equation, but I believe there must be an answer. So could anyone help me to find whats the problem?
EDIT = added values of B and Omega

Risposta accettata

Alberto Altozano
Alberto Altozano il 10 Dic 2018
I got it:
%this is the function i used to solve it. I'm solving it with the bisection method for numerical equations
function [c, err, yc] = bisect (f, a, b, delta)
ya = feval(f, a);
yb = feval(f, b);
if ya*yb > 0, end
max1 = 1 + round((log(b-a) - log(delta)) / log(2));
for k = 1:max1
c = (a + b) / 2;
yc = feval(f, c);
if yc == 0
a = c;
b = c;
elseif yb*yc > 0
b = c;
yb = yc;
else
a = c;
ya = yc;
end
if b-a < delta, break, end
end
c = (a + b) / 2;
err = abs(b - a);
yc = feval(f, c);
%this is the while I had to use
i = 1;
while i ~= 1001
X2L = (i-1)/1000;
F =@(T) exp(OMEGA./(R.*T).*(1+3*B-4*B.*X2L).*X2L.^2+HVAP1/R.*(1/TVAP1-1./T)).*(1-X2L)+exp(OMEGA./(R.*T)*(1+B-4*B*X2L).*(1-X2L).^2+HVAP2/R.*(1/TVAP2-1./T)).*X2L-1;
[T(i),err(i),yc(i)] = bisect(F,340,390,0.0001);
i = i+1;
end
X2L = [0:0.001:0.999];

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by