MATLAB Answers

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

56 views (last 30 days)
N/A
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 Comments

Sign in to comment.

Answers (1)

Image Analyst
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???

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by