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

56 views (last 30 days)
N/A on 19 Jan 2016
Commented: Rena Berman on 6 May 2021 at 17:44
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 CommentsShowHide 1 older comment
Rena Berman on 6 May 2021 at 17:44

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