What's the fastest way to approximate the period of data using Octave?

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-04-03T19:43:28Z Indexed on 2010/04/03 19:53 UTC
Read the original article Hit count: 217

I have a set of data that is periodic (but not sinusoidal). I have a set of time values in one vector and a set of amplitudes in a second vector. I'd like to quickly approximate the period of the function. Any suggestions?

Specifically, here's my current code. I'd like to approximate the period of the vector x(:,2) against the vector t. Ultimately, I'd like to do this for lots of initial conditions and calculate the period of each and plot the result.

function xdot = f (x,t)
         xdot(1) =x(2);
         xdot(2) =-sin(x(1));
endfunction

x0=[1;1.75];     #eventually, I'd like to try lots of values for x0(2)
t = linspace (0, 50, 200);


x = lsode ("f", x0, t)

plot(x(:,1),x(:,2));

Thank you!

John

© Stack Overflow or respective owner

Related posts about octave

Related posts about mathematical-equations