help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Numerical Differentiation and Integration of Array Data


From: syberraith
Subject: Re: Numerical Differentiation and Integration of Array Data
Date: Sun, 4 Dec 2011 21:37:29 -0800 (PST)

I'm getting syntax errs with this, although I'm running the debian package of
octave, which is far from the newest version:

dat_pts = 1000;

gyr_rpm = 12000;
xrm_rpm = 1000;
gyr_rad = 0.025;
xrm_rad = 0.15;

gyr_vel = 2 * pi * gyr_rpm / 60;
xrm_vel = 2 * pi * xrm_rpm / 60;

p = 60 / gyr_rpm;
h = p / ( dat_pts - 1 );
g = h / 2;

t = linspace(0 - g, p + g, dat_pts + 1);

function [f, s1, s2] = process (f, t, h, g)
   a = (f(t+g) - f(t-g))/h;
   a = h.*(a(1:end-1) + a(2:end))./2;
   s1 = f(t(end)) - f(t(1));
   s2 = h * sum (f);
endfunction 

function y = raw_vel(x, gyr_rad, gyr_vel, xrm_rad, xrm_vel)
   y = sqrt((-gyr_rad*gyr_vel*sin(gyr_vel*x) + xrm_rad*xrm_vel)^2 +
(gyr_rad*gyr_vel*cos(gyr_vel*x))^2 );
endfunction

function y = del_the(x, gyr_rad, gyr_vel, xrm_rad, xrm_vel)
   raw_ang = atan2(-gyr_rad*gyr_vel*sin(gyr_vel*x) + xrm_rad*xrm_vel,
gyr_rad*gyr_vel*cos(gyr_vel*x));
   tan_ang = atan2(sin(gyr_vel*x), cos(gyr_vel*x));
   y = raw_ang + tan_ang;
   y(y > pi) -=  2 * pi; 
endfunction

tan_vel = @(t) cos(del_the(t, gyr_rad, gyr_vel, xrm_rad, xrm_vel))*raw_vel
(t, gyr_rad, gyr_vel, xrm_rad, xrm_vel);

hor_vel = @(t) -sin(gyr_vel*t)*cos( del_the(t, gyr_rad, gyr_vel, xrm_rad,
xrm_vel))*raw_vel(t, gyr_rad, gyr_vel, xrm_rad, xrm_vel);

ver_vel = @(t) cos(gyr_vel*x)*cos( del_the(t, gyr_rad, gyr_vel, xrm_rad,
xrm_vel))*raw_vel(t, gyr_rad, gyr_vel, xrm_rad, xrm_vel);

[tan_f, tan_s1, tan_s2] = process(tan_vel, t, h, g)
[hor_f, hor_s1, hor_s2] = process(hor_vel, t, h, g)
[ver_f, ver_s1, ver_s2] = process(ver_vel, t, h, g)



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Numerical-Differentiation-and-Integration-of-Array-Data-tp4145498p4159361.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]