How to Solve Multiple Groups of Ternary Linear Equations using for loop?

1 回表示 (過去 30 日間)
feng zhao
feng zhao 2022 年 4 月 19 日
コメント済み: feng zhao 2022 年 4 月 19 日
There is a three-variable linear equation system below, and its parameters have xt and yt. I want to substitute the first xt and all yt into this equation to get 501 sets of three-variable linear equations, and then find 501 solutions of A1, then Repeat this operation for other xt to get 501*501 A1 in total. What should I do?
format compact
warning off
x1=600;y1=0;z1=1200;
x2=800;y2=0;z2=-1200;
syms A1 E1 A2 E2 out
yt=500;zt=500;
fprintf('A1');
i=0;
yt=-1000:2:0;
for xt=-5000:10:0
i=i+1;
yt=-1000:2:0;
eq1=(x1-xt).*(tan(A1)-tan(A2))+((x1-x2).*tan(A2)-(z1-z2));
eq2=(y1-yt).*(tan(A1)-tan(A2))+((x1-x2).*tan(A2)-(z1-z2)).*(tan(E1).*sec(A1));
eq3=(z1-zt).*(tan((A1))-tan((A2)))+((x1-x2).*tan(A2)-(z1-z2)).*tan((A1));
A1s=solve([eq1,eq2,eq3],[A1,A2,E1]);
fprintf('the %dth A1 when x is %d\n',i);
A1s.A1
double(A1s.A1)
end
  2 件のコメント
John D'Errico
John D'Errico 2022 年 4 月 19 日
Um, they are NOT linear equations!!!!!
The unknowns in your solve are A1, A2, E1. You have products of variables. Only in your dreams are these linear equations.
feng zhao
feng zhao 2022 年 4 月 19 日
lol, well, i know this problem too, i'll try to replace this equation

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by