How do i solve 2 equations for 2 unknowns?

3 views (last 30 days)
Swaroop
Swaroop on 19 Dec 2014
Commented: Roger Stafford on 23 Sep 2016
I have just started to learn MATLAB. I just need to know how do i code the following to find the unknowns and find the intersection points? I have to solve 8 sets of equations and find the intersecting co-ordinates. Here is the format of the equations which is to be used. Except (X,Y) all other values are known in each system of equation. I need to find (X,Y) in each system and find the intersecting point/points.
VT1= sqrt((X1-X)^2+(Y1-Y)^2) and VT2= sqrt((X2-X)^2+(Y2-Y)^2)
VT2= sqrt((X2-X)^2+(Y2-Y)^2) and VT3= sqrt((X3-X)^2+(Y3-Y)^2)
VT3= sqrt((X3-X)^2+(Y3-Y)^2) and VT4= sqrt((X4-X)^2+(Y4-Y)^2)
VT4= sqrt((X4-X)^2+(Y4-Y)^2) and VT5= sqrt((X5-X)^2+(Y5-Y)^2)
VT5= sqrt((X5-X)^2+(Y5-Y)^2) and VT6= sqrt((X6-X)^2+(Y6-Y)^2)
VT6= sqrt((X6-X)^2+(Y6-Y)^2) and VT7= sqrt((X7-X)^2+(Y7-Y)^2)
VT7= sqrt((X7-X)^2+(Y7-Y)^2) and VT8= sqrt((X8-X)^2+(Y8-Y)^2)
VT8= sqrt((X8-X)^2+(Y8-Y)^2) and VT1= sqrt((X1-X)^2+(Y1-Y)^2)

Answers (1)

Roger Stafford
Roger Stafford on 19 Dec 2014
For each of the eight pairs of equations you are asking for the two intersections of two circles. Here is a direct solution extracted from Answers #132554, 5 Jun 2014, which does not use iteration.
Let P1 = [x1;y1] and P2 = [x2;y2] be column vectors for the coordinates of the two centers of the circles and let r1 and r2 be their respective radii.
d2 = sum((P2-P1).^2);
P0 = (P1+P2)/2+(r1^2-r2^2)/d2/2*(P2-P1);
t = ((r1+r2)^2-d2)*(d2-(r2-r1)^2);
if t <= 0
fprintf('The circles don''t intersect.\n')
else
T = sqrt(t)/d2/2*[0 -1;1 0]*(P2-P1);
Pa = P0 + T; % Pa and Pb are circles' intersection points
Pb = P0 - T;
end
The coordinates of vectors 'Pa' and 'Pb' are the two possible solutions to the equations of the two circles.
  4 Comments
Ken
Ken on 23 Sep 2016
In Robotics we have forward and inverse Kinematics equations i.e. A*Si = B*phi. Can this approach be used to solve these equations?
Roger Stafford
Roger Stafford on 23 Sep 2016
Very likely the answer is ‘no’, but you should accurately describe the quantities A, Si, B, and phi to get a reliable answer, and also you should probably establish a separate question for it in this ‘ånswers’ forum.

Sign in to comment.

Categories

Find more on Elementary Polygons in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!