Fslove don't find the right solution
조회 수: 1 (최근 30일)
이전 댓글 표시
I try to solve a non linear system, but Fsolve can't solve it.
F=@(q)[sqrt((q(1)-5)^2 + q(2)^2 + q(3)^2 )-sqrt( q(1)^2 + (q(2)+10)^2 + q(3)^2)-Rez1;
sqrt(q(1)^2 + (q(2)+10)^2 + q(3)^2 )-sqrt( q(1)^2 + (q(2)-10)^2 + q(3)^2)-Rez2;
sqrt( q(1)^2 + (q(2)-10)^2 + q(3)^2 )-sqrt( q(1)^2 + q(2)^2 + q(3)^2)-Rez3];
q0=[50,0,0];
options = optimset('Display','iter','maxfunevals',500,'tolfun',1e-1,'tolx',1e-1,'tolcon',1e-2);
fsolve(F,q0,options)
Rez1,2,3 are some variable that I calculate before that. And the response of matlab is
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171187/image.png)
I try to modify the values of tolfun and tolx, but no succes. Any help?
댓글 수: 0
답변 (2개)
Star Strider
2018년 3월 12일
We don’t have your ‘Rez’ constants, so we can’t run your code.
However, using 0 as any initial parameter estimate results in a much more difficult optimisation.
Try this instead:
q0=[50,-1,1];
댓글 수: 2
Star Strider
2018년 3월 12일
With this initial estimate:
q0 = randi(99, 3, 1);
and assigning an output for the fsolve result:
Qv = fsolve(F,q0,options)
I get solutions that appear to converge to the same value to ‘q(1)’ and ‘q(3)’, with ‘q(2)’ less well defined:
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the selected value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
Qv =
31.0008e+000
103.9495e-003
37.4620e+000
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the selected value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
Qv =
30.5924e+000
208.7728e-003
36.5371e+000
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the selected value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
Qv =
31.3360e+000
19.2740e-003
37.2166e+000
Alex Sha
2019년 12월 11일
I get the results:
1:
q1: 31.25152
q2: -3.3648581278838E-15
q3: -37.1015437789933
2:
q1: 31.2515200000001
q2: 1.37892196278414E-15
q3: 37.1015437789935
댓글 수: 0
참고 항목
카테고리
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!