# Fslove don't find the right solution

1 Ansicht (letzte 30 Tage)
Jessie Bessel am 12 Mär. 2018
Beantwortet: Alex Sha am 11 Dez. 2019
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?
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Star Strider am 12 Mär. 2018
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.
q0=[50,-1,1];
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Star Strider am 12 Mär. 2018
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

Melden Sie sich an, um zu kommentieren.

Alex Sha am 11 Dez. 2019
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 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Systems of Nonlinear Equations finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!