Problem with the fsolve function in MatLab

1 visualizzazione (ultimi 30 giorni)
This is the function I try using for determining both CA0 and CB0
function F = root2d(x)
T12 = 22 + 273.15;
R = 8.314;
k1 = 74900*exp(-8050/(R*T12));
xA1 = 0.788;
xA2 = 0.974;
xA0 = 0;
t1 = 30;
t2 = 120;
%x(1) = CA0
%x(2) = CB0
F(1) = (2*log(1-xA1) - 2 * log(-x(1)*xA1 + 2*x(2))) - (2*log(1-xA0) - 2 * log(2*x(2))) - k1*t1*(x(2)-2*x(1));
F(2) = (2*log(1-xA2) - 2 * log(-x(1)*xA2 + 2*x(2))) - (2*log(1-xA0) - 2 * log(2*x(2))) - k1*t2*(x(2)-2*x(1));
end
Then I input it in this program:
fun = @root2d
x0 = [0,0];
x = fsolve(fun,x0)
disp(x)
Can someone help with what is going wrong here?
Why the problem can't be solved?
May it be related to the values [0,0]?
Because if both of them are 0 at the same time the equation can't be solved.
Thanks everyone in advance!
  1 Commento
Walter Roberson
Walter Roberson il 6 Ott 2020
Yes, you will need to use a different initial conditon.
Also you will probably need to use an options structure to increase the iterations limit.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 6 Ott 2020
fsolve can solve the system, but it requires that the second x input be between about 5e-6 and 1.1e-5 . Smaller values will lead to complex solutions; larger values will lead to no solution with the results not being even remotely close.

Più risposte (0)

Categorie

Scopri di più su Mathematics and Optimization in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by