07-22-2010 04:23 AM
HI there,
I am currently working on solving the equations of motion for a simple pendulum in a scriptnode and using the solution to animate a CAD vrml model. My scriptnode calls a function which evaluates the ODE's which is in matlab and the result is two vectors; the angle and the angular velocity. My results are simlar (only slight differences, possibly due to rounding error) for the angle which is really all I need but the velocity results are significantly off. I run the exact same code in MATLAB and the results appear to be correct but when I run it in labview, the velocity is different in magnitude and also out of phase. i.e. when the angle is increasing the velocity is negative...
I have attached my code for both labview and matlab and am really interested in why these differences occur. I am unable to attach a vrml file so if anyone wants to look at code, the vrml file part will need to be disabled!
Any help will be much appreciated!!!!
//////////////////////////////////////////////////////////////////////////////////////////////
//eqtn.m
function dy = eqtn(t,y,m,phi,k,l,g,alpha);
dy = [
y(2)
-(phi*y(2)+l(1)*m(2)*g*sin(y(1)))/(l(1)^2*m(2)*sin(y(1))^2+l(1)^2*m(2)*cos(y(1))^2)
]
end
////////////////////////////////////////////////////////////////////////////////////////
//main.m
g = 9.81;
m=[1,0.2];
phi = 0.1;
lambda = 1;
k = [40];
l = [0.3];
angle_off_vert = pi/4;
alpha = pi-angle_off_vert;
u0 = 0;
theta0 = pi/2 + pi/4;
y=[theta0,u0];
% time = linspace(0,5,100);
time = 0:0.02:3;
[T,Y_complete] = ode23(@eqtn,time,y,[],m,phi,k,l,g,alpha);
//////////////////////////////////////////////////////////////////////////////////////////
07-22-2010 06:02 PM
I have come to a solution! A typo by me!!!
Thanks to all those who thought about my problem!
07-23-2010 07:41 AM
That is why those of us who like LV dislike text based languages: We can't type! Atr leaesrt ngott vrwryy acuratetttllluy
Lynn