Problem with the fsolve function in MatLab

1 view (last 30 days)
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 Comment
Walter Roberson
Walter Roberson on 6 Oct 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.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 6 Oct 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.

More Answers (0)

Categories

Find more on Symbolic Math Toolbox 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!