I am unable to solve my system of equations using MATLAB, Can anyone go through the code and suggest me some?
12 ビュー (過去 30 日間)
古いコメントを表示
CHANDRA SEKHAR UTLA
2021 年 4 月 19 日
編集済み: CHANDRA SEKHAR UTLA
2021 年 4 月 19 日
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.
0 件のコメント
採用された回答
Walter Roberson
2021 年 4 月 19 日
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)
eqn2_b = simplify(subs(eqn2, z, zsol))
Look at that eqn2_b and notice that it has no x and no y. Your equations do not have full rank.
1 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!