How can I solve three unknowns with three equations in Matlab?

39 views (last 30 days)
I am new to Matlab and trying to solve these equations in Matlab.
(1.92-x)^2+(-0.88-y)^2=r^2
(1.42-x)^2+(1.22-y)^2=(r+343(0.00638))^2
(-1.51-x)^2+(1-y)^2=(r+343(0.01149))^2
I am very unsure of how this can be done. This must be possible in a software like Matlab. What code do you think it is best to use when solving this?

Accepted Answer

John D'Errico
John D'Errico on 12 Feb 2016
Edited: John D'Errico on 12 Feb 2016
Easily enough done using the symbolic toolbox.
syms x y r
E1 = (1.92-x)^2+(-0.88-y)^2 == r^2;
E2 = (1.42-x)^2+(1.22-y)^2 == (r+343*(0.00638))^2;
E3 = (-1.51-x)^2+(1-y)^2 == (r+343*(0.01149))^2;
result = solve(E1,E2,E3)
result =
r: [2x1 sym]
x: [2x1 sym]
y: [2x1 sym]
vpa(result.r)
ans =
-0.015481067535873645827800666354194
-0.30809941998244195263749288776231
vpa(result.x)
ans =
1.9293936680622001322345796823646
1.7349298832558521137294030854302
vpa(result.y)
ans =
-0.89230538306545075129564568787526
-0.63367845307033202264344475680987
So there are two possible solutions.
These are the equations of three circles, with fixed centers, and variable radii that depends on r. See that r came out negative in all three cases, but that is irrelevant. The radii of the circles are not negative. (With only a little effort, the three circles can be plotted, along with the solutions.)
Again, Gaussian elimination is not possible here, although one could solve the problem using pencil and paper.

More Answers (1)

Disha
Disha on 17 Nov 2022
syms x y r E1 = (1.92-x)^2+(-0.88-y)^2 == r^2; E2 = (1.42-x)^2+(1.22-y)^2 == (r+343*(0.00638))^2; E3 = (-1.51-x)^2+(1-y)^2 == (r+343*(0.01149))^2; result = solve(E1,E2,E3) result = r: [2x1 sym] x: [2x1 sym] y: [2x1 sym]

Community Treasure Hunt

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

Start Hunting!