Fslove don't find the right solution

조회 수: 1 (최근 30일)
Jessie Bessel
Jessie Bessel 2018년 3월 12일
답변: Alex Sha 2019년 12월 11일
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
I try to modify the values of tolfun and tolx, but no succes. Any help?

답변 (2개)

Star Strider
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
Jessie Bessel
Jessie Bessel 2018년 3월 12일
v=340;
Tsos1=1.35
Tsos2=1.47
Tsos3=1.47
Tsos4=1.44
Rez1=v*(Tsos1-Tsos2)/10
Rez2=v*(Tsos2-Tsos3)/10
Rez3=v*(Tsos3-Tsos4)/10
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)
Star Strider
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
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

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by