# How to solve a system of equations?

3 Ansichten (letzte 30 Tage)
Jessie Bessel am 27 Feb. 2018
Kommentiert: Walter Roberson am 1 Mär. 2018
I try to solve a non=linear equtions system, but it doesn't work. I missed something?
F=@(x)[sqrt((x(1)-5)^2 + x(2)^2 + x(3)^2 )-sqrt( x(1)^2 + (x(2)+10)^2 + x(3)^2) +0.34;
sqrt(x(1)^2 + (x(2)+10)^2 + x(3)^2 )-sqrt( x(1)^2 + (x(2)-10)^2 + x(3)^2);
sqrt( x(1)^2 + (x(2)-10)^2 + x(3)^2 )-sqrt( x(1)^2 + x(2)^2 + x(3)^2)];
x0=[50;0;0];
fsolve(F,x0)
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Alan Weiss am 27 Feb. 2018
You have an errant space just before "+0.34" that is confusing the parser. Try this:
F=@(x)[sqrt((x(1)-5)^2 + x(2)^2 + x(3)^2 )-sqrt( x(1)^2 + (x(2)+10)^2 + x(3)^2)+0.34;
sqrt(x(1)^2 + (x(2)+10)^2 + x(3)^2 )-sqrt( x(1)^2 + (x(2)-10)^2 + x(3)^2);
sqrt( x(1)^2 + (x(2)-10)^2 + x(3)^2 )-sqrt( x(1)^2 + x(2)^2 + x(3)^2)];
x0=[50;0;0];
fsolve(F,x0)
You might need to include some options or a better start point for a good answer.
Alan Weiss
MATLAB mathematical toolbox documentation
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Walter Roberson am 1 Mär. 2018
They are the value of the vector x at the time that fsolve figured out that the system could not be solved.

Melden Sie sich an, um zu kommentieren.

Roger Stafford am 28 Feb. 2018
To solve these you would have to satisfy both
x(1)^2 + (x(2)+10)^2 + x(3)^2 = x(1)^2 + (x(2)-10)^2 + x(3)^2
x(1)^2 + (x(2)-10)^2 + x(3)^2 = x(1)^2 + x(2)^2 + x(3)^2)
and since the x(1) and x(3) terms cancel would require simply
(x(2)+10)^2 = (x(2)-10)^2
(x(2)-10)^2 = x(2)^2
The first of these requires that x(2) = 0 while the second requires that x(2) = 5. These are mutually incompatible and therefore there are no simultaneous solutions to your equations. That is why "it doesn't work".
##### 1 KommentarKeine anzeigenKeine ausblenden
Jessie Bessel am 28 Feb. 2018
when i do that, the solver tell me that there is no solution found, but what are the value from ans?Originally, there should have been the solutions, but if the system doesn't have solutions, what are they?

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!

Translated by