I am unable to solve my system of equations using MATLAB, Can anyone go through the code and suggest me some?

1 view (last 30 days)
Hello all,
I am trying to solve a system of equations (one quadratic, two linear equations) using MATLAB 'solve' command. But everytime it is not showing the result. Will you please go through the code and suggest me some.
% Here is my code
syms x y z
eqn1 = (x-x1)*(x-x2)+ (y-y1)*(y-y2)+(z-z1)*(z-z2)== d1*d2*cosd(intersxn_angle);
eqn2 = (x1-x2)*(x1-x)+(y1-y2)*(y1-y)+(z1-z2)*(z1-z)== d1*d*cosd(theta2);
eqn3 =(x2-x1)*(x2-x)+ (y2-y1)*(y2-y)+(z2-z1)*(z2-z) == d*d2*cosd(theta1);
eqns = [eqn1, eqn2 eqn3];
Vars =[x y z];
[solx, soly, solz] = solve(eqns,vars);
In the above code x1, y1, z1, x2, y2, z2, d1, d2, d, intersxn_angle, theta1, and, theta2 are known to me. The only unkowns are x, y, z . When i am running the above code, every time i am getting x, y, z as ox1 symbol, which means empty result. In the above code, whether my equations are inconsistent or i need to use any other command or another way to equations. Please suggest me some. I am stuck with this code.
Thank you.

Accepted Answer

Walter Roberson
Walter Roberson on 19 Apr 2021
syms x1 x2 y1 y2 z1 z2
syms d d1 d2 intersxn_angle theta1 theta2
syms x y z
eqn1 = (x-x1)*(x-x2)+ (y-y1)*(y-y2)+(z-z1)*(z-z2)== d1*d2*cosd(intersxn_angle);
eqn2 = (x1-x2)*(x1-x)+(y1-y2)*(y1-y)+(z1-z2)*(z1-z)== d1*d*cosd(theta2);
eqn3 =(x2-x1)*(x2-x)+ (y2-y1)*(y2-y)+(z2-z1)*(z2-z) == d*d2*cosd(theta1);
zsol = solve(eqn3,z)
zsol = 
eqn2_b = simplify(subs(eqn2, z, zsol))
eqn2_b = 
Look at that eqn2_b and notice that it has no x and no y. Your equations do not have full rank.
  1 Comment
CHANDRA SEKHAR UTLA
CHANDRA SEKHAR UTLA on 19 Apr 2021
Edited: CHANDRA SEKHAR UTLA on 19 Apr 2021
Thank you walter Roberson for giving your time, and suggestion. So eqn 2 and eqn 3 are represnting same. So, I need to provide another equation for finding x, y and z.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics 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!