Problem with the fsolve function in MatLab

1 回表示 (過去 30 日間)
Andrian Mirza
Andrian Mirza 2020 年 10 月 6 日
回答済み: Walter Roberson 2020 年 10 月 6 日
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
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
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 件)

カテゴリ

Help Center および File ExchangeMathematics and Optimization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by