フィルターのクリア

solve systems of linear equation in for loop

2 ビュー (過去 30 日間)
Andrew Poissant
Andrew Poissant 2017 年 4 月 9 日
コメント済み: Andrew Poissant 2017 年 4 月 10 日
I want to solve a system of 3 equations, all of which are in a for loop. Is there any way to solve for [dx, dy, dt] 180 times and get all of those values?
syms dx dy dt
ax = 0;
ay = 0;
az = -9.8;
u = 16;
phi = 0;
h1 = 60.96;
h2 = 0;
dz = h1 - h2;
for theta = 1:180;
u_x(theta) = u*cosd(theta)*cosd(phi);
u_y(theta) = u*sind(theta)*cosd(phi);
u_z(theta) = u*sind(phi);
f1 = dx(theta) == u_x(theta)*dt + 0.5*ax*dt^2;
f2 = dy(theta) == u_y(theta)*dt + 0.5*ay*dt^2;
f3 = dz(theta) == -u_z(theta)*dt + 0.5*az*dt^2;
[dx, dy, dt] = solve([f1, f2, f3], [dx, dy, dt]);
end

採用された回答

Torsten
Torsten 2017 年 4 月 10 日
ax = 0;
ay = 0;
az = -9.8;
u = 16;
phi = 0;
h1 = 60.96;
h2 = 0;
dz = h1 - h2;
theta = 1:1:180;
u_x = u*sind(theta)*cosd(phi);
u_y = u*sind(theta)*cosd(phi);
u_z = u*sind(phi);
dt = u_z/az + sqrt(u_z.^2+2*dz*az)/az; (or dt = u_z/az - sqrt(u_z.^2+2*dz*az)/az;)
dx = u_x.*dt + 0.5*ax*dt.^2;
dy = u_y.*dt + 0.5*ay*dt.^2;
Best wishes
Torsten.
  1 件のコメント
Andrew Poissant
Andrew Poissant 2017 年 4 月 10 日
Thanks! I guess I was overcomplicating things. Just had to solve in terms of dt first

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by