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: Mon, 5 Dec 2011 15:11:02 -0800 (PST)

Hey C. 

I got this mostly working, the anonymous function.

The only problem fully implementing you scheme is getting the anonymous
function to pass the four parameter values to the raw_vel and del_the
functions.

I had to resort to using some global variables.  Here's what I got working.

global gyr_rad gyr_vel xrm_rad xrm_vel

dat_pts = 1000;

gyr_rpm = 12000;
xrm_rpm = 300;
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 [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(a);
endfunction 

function y = raw_vel (x)

   global 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)

   global 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 = @(s) -cos( del_the(s) ) .* raw_vel(s);

[s1, s2] = process(tan_vel, t, h, g)


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


reply via email to

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