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에서 Numbers and Precision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!