Problem with the fsolve function in MatLab
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2020-10-6
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.
采纳的回答
Walter Roberson
2020-10-6
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!