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

조회 수: 3 (최근 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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by