Trying to code two angular acceleration equations and angles

1 回表示 (過去 30 日間)
Hendrix
Hendrix 2012 年 12 月 6 日
I wrote
%initial condition of theta angle (precession angle) tt (1) = 0.5;
ttd (1) = 0; ttdd (1) = 0;
el (1) = 0;
eld (1) = (m*g*sin(tt(1)))/(C*omega_s); eldd (1) = 0;
for
ttdd(i+1) =(M_y-((C*omega_s*sin(tt(i)))*((M_x-(C*ttd(i)*omega_s)+(A*eldd(i)*sin(tt(i))))/(((-2)*A*ttd(i)*cos(tt(i)))+(C*ttd(i)*cos(tt(i)))))));
eldd (i+1) = (M_x+ ((2*A*ttd(i)*cos(tt(i)))*((M_y-(A*ttdd(i)))/(C*omega_s*sin(tt(i)))))-(C*ttd(i)*omega_s)-(C*ttd(i)*((M_y-(A*ttdd(i)))/(C*omega_s*sin(tt(i))))*cos(tt(i))));
ttd(i+1) = (ttdd(i+1)*delta_t)+ttd(i);
tt (i+1) = ((ttd(i+1)*delta_t))+tt(i);
eld(i+1) = (eldd(i+1)*delta_t)+eld(i);
el (i+1) = ((eld(i+1)*delta_t))+el(i);
in the Matlab.
end
My inputs are M_x and M_y and trying to get the angles as outputs. All my answers are NAN... Please point out where I got wrong. Thanks
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 12 月 6 日
complete your for loop. what is
for
in your program? also, give all data to allow testing your code

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

回答 (1 件)

Muthu Annamalai
Muthu Annamalai 2012 年 12 月 6 日
To give you a hint, 1/0 = Inf, 0/0 = NaN. So you need to avoid doing these things in your code.
Special case the situations when you have a potential 0/0 should solve your problem.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by