Trying to code two angular acceleration equations and angles
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!