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

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Stephen23
Stephen23 il 15 Apr 2021
Modificato: Ashish il 21 Apr 2021
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

Accedi per commentare.

Risposte (1)

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

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by