[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.
- Re: Numerical Differentiation and Integration of Array Data, (continued)
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/04
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/04
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data, Francesco Potortì, 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data, Francesco Potortì, 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data, Francesco Potortì, 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data, Francesco Potortì, 2011/12/05
- Re: Numerical Differentiation and Integration of Array Data,
syberraith <=
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/06
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/06
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/06
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/06
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/07
- Re: Numerical Differentiation and Integration of Array Data, Przemek Klosowski, 2011/12/07
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/07
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/08
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/09
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/07