Facing problem in solving simultaneous nonlinear equation with 3 unknowns
1 回表示 (過去 30 日間)
古いコメントを表示
x = optimvar('x',3);
eq1 = 0.7133/(1-0.7133)== x(1).*(1-exp(-(1-x(1)).*127./x(2))).*exp(-127/x(3))/(1-x(1));
eq2 = 0.8058/(1-0.8058)== x(1).*(1-exp(-(1-x(1)).*229./x(2))).*exp(-229/x(3))/(1-x(1));
eq3 = 0.7133/(1-0.8708)== x(1).*(1-exp(-(1-x(1)).*421./x(2))).*exp(-421/x(3))/(1-x(1));
prob = eqnproblem;
prob.Equations.eq1 = eq1;
prob.Equations.eq2 = eq2;
prob.Equations.eq3 = eq3;
show(prob)
x0.x = [0.9 410 8000];
[sol,fval,exitflag] = solve(prob,x0);
disp(sol.x)
Here is my codes and error popout. I cant get the correct ans
Hope other can help me :) thanks in advance
3 件のコメント
John D'Errico
2023 年 12 月 4 日
Note that the presence of x1, x2, and x3 both inside and out of exponentials makes this almost certainly one where solve would never have succeeded anyway. With one unknown, the Lambert W and its close cousin, the Wright-Omega function will sometimes succeed. But not with 3 unknowns. So fsolve or lsqnonlin are the only real choices.
回答 (1 件)
Matt J
2023 年 12 月 4 日
編集済み: Matt J
2023 年 12 月 4 日
What @Dyuman Joshi says is true. However, your equations don't seem to make sense without upper and lower bounds on x. For example, since you are dividing by x(2) and x(3) in certain places, you are clearly assuming them to be bounded away from zero somehow... When I impose bounds, a solution (least squares only) is found without hitting the iteration limit.
x = optimvar('x',3,'Lower',[0,0,0],'Upper',[1,inf,inf]);
eq1 = 0.7133/(1-0.7133)== x(1).*(1-exp(-(1-x(1)).*127./x(2))).*exp(-127/x(3))/(1-x(1));
eq2 = 0.8058/(1-0.8058)== x(1).*(1-exp(-(1-x(1)).*229./x(2))).*exp(-229/x(3))/(1-x(1));
eq3 = 0.7133/(1-0.8708)== x(1).*(1-exp(-(1-x(1)).*421./x(2))).*exp(-421/x(3))/(1-x(1));
prob = eqnproblem;
prob.Equations.eq1 = eq1;
prob.Equations.eq2 = eq2;
prob.Equations.eq3 = eq3;
x0.x = [0.9 410 8000];
[sol,fval,exitflag,output] = solve(prob,x0);
disp(sol.x)
exitflag,output
参考
カテゴリ
Help Center および File Exchange で Systems of Nonlinear Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!