Trying to code two angular acceleration equations and angles

1 view (last 30 days)
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

Answers (1)

Muthu Annamalai
Muthu Annamalai on 6 Dec 2012
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.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!