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: Sat, 3 Dec 2011 04:58:43 -0800 (PST)

You're right about the h = p ./ ( n - 1).  It's been a long time since I did
any coding.  :)

And about the 1256 and 0.005.  This is what I was actually aiming for, a
rotational time period of 0.005 sec, 200 cps.

***

n = 100000;  # Number of data points
p = 0.005;   # Time period
h = p ./ (n - 1);  # dt
g = h ./ 2;  # dt/2 for my version of central diff

t = linspace(0, p , n);

f = ( sin(400 .* pi .* (t + g)) .- sin(400 .* pi .* (t - g)) ) ./ h;
 
s = sum(h .* (f(1:end-1) + f(2:end)) ./ 2)

***

s =  -1.9872e-11

That's much more satisfying!

I was unsure were the dot operators were needed and where non-dot operators
could be used.  So just for * and /?

Now I'll have to figure out what you did on the evaluations.

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


reply via email to

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