Fslove don't find the right solution

3 次查看(过去 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
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