Why the output shows “NaN NaN" ? Please check for me thanks

조회 수: 1 (최근 30일)
N/A
N/A 2016년 1월 19일
댓글: Rena Berman 2021년 5월 6일
clc
clf
hold off
tf = 0.005;
theta10 = -19*pi/180;
theta1tf = 30*pi/180;
theta20 = 44*pi/180;
theta2tf = 90*pi/180;
xe=3.33;
ye=4.23;
L1=5;
L2=2;
f0=[L1*cos(theta10) + L2*cos(theta10 + theta20); L1*sin(theta10) + L2*sin(theta10 + theta20)];
f=[L1*cos(theta10) + L2*cos(theta10 + theta20)-xe; L1*sin(theta10) + L2*sin(theta10 + theta20)-ye];
theta1new=theta10;
theta2new=theta20;
% Equations of motion
epsilon=1e-3;
while norm(f)>epsilon
T = [ tf.^5 tf.^4 tf.^3
5*tf.^4 4*tf.^3 3*tf.^2
20*tf.^3 12*tf.^2 6*tf ];
c = [ theta10; 0; 0 ];
disp('Coefficients for theta1 motion:')
a = T\c
d = [ theta20; 0; 0 ];
disp('Coefficients for theta2 motion:')
b= T\d
tf=tf+0.005;
tq = [ tf.^5; tf.^4; tf.^3 ];
theta10 = theta10 + a'*tq;
theta20 = theta20 + b'*tq;
f=[L1*cos(theta10) + L2*cos(theta10 + theta20)-xe; L1*sin(theta10) + L2*sin(theta10 + theta20)-ye];
norm(f);
end
f
tf
  댓글 수: 2
Stephen23
Stephen23 2021년 4월 15일
편집: Ashish 2021년 4월 21일
Original question on 19th January 2016:
Why the output shows “NaN NaN" ? Please check for me thanks
clc
clf
hold off
tf = 0.005;
theta10 = -19*pi/180;
theta1tf = 30*pi/180;
theta20 = 44*pi/180;
theta2tf = 90*pi/180;
xe=3.33;
ye=4.23;
L1=5;
L2=2;
f0=[L1*cos(theta10) + L2*cos(theta10 + theta20); L1*sin(theta10) + L2*sin(theta10 + theta20)];
f=[L1*cos(theta10) + L2*cos(theta10 + theta20)-xe; L1*sin(theta10) + L2*sin(theta10 + theta20)-ye];
theta1new=theta10;
theta2new=theta20;
% Equations of motion
epsilon=1e-3;
while norm(f)>epsilon
T = [ tf.^5 tf.^4 tf.^3
5*tf.^4 4*tf.^3 3*tf.^2
20*tf.^3 12*tf.^2 6*tf ];
c = [ theta10; 0; 0 ];
disp('Coefficients for theta1 motion:')
a = T\c
d = [ theta20; 0; 0 ];
disp('Coefficients for theta2 motion:')
b= T\d
tf=tf+0.005;
tq = [ tf.^5; tf.^4; tf.^3 ];
theta10 = theta10 + a'*tq;
theta20 = theta20 + b'*tq;
f=[L1*cos(theta10) + L2*cos(theta10 + theta20)-xe; L1*sin(theta10) + L2*sin(theta10 + theta20)-ye];
norm(f);
end
f
tf
Rena Berman
Rena Berman 2021년 5월 6일
(Answers Dev) Restored edit

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2016년 1월 19일
Probably because your a and b numbers get so huge. Do you know they're like 10^306 and increasing???

태그

Community Treasure Hunt

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

Start Hunting!

Translated by