使用 Octave 估算数据周期的最快方法是什么?
我有一组周期性的数据(但不是正弦曲线)。我在一个向量中有一组时间值,在第二个向量中有一组幅度。我想快速估算出函数的周期。有什么建议吗?
具体来说,这是我当前的代码。我想近似向量 x(:,2) 相对于向量 t 的周期。最终,我想对许多初始条件执行此操作,并计算每个条件的周期并绘制结果。
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));
谢谢你!
约翰
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看一下自相关函数。
来自 维基百科
Paul Bourke 描述了如何基于快速傅里叶变换有效计算自相关函数(链接 )。
Take a look at the auto correlation function.
From Wikipedia
Paul Bourke has a description of how to calculate the autocorrelation function effectively based on the fast fourier transform (link).
离散傅立叶变换可以给出周期性。较长的时间窗口可以提供更高的频率分辨率,因此我将您的
t
定义更改为t = linspace(0, 500, 2000)
。时域 http://img402.imageshack.us/img402/8775/timedomain.png< /a> (这里有一个绘图链接,它在托管站点)。
你可以这样做:
频域 http://img406.imageshack.us/img406/2696/ freqdomain.png 绘图链接。
查看图表,第一个峰值位于 0.06 Hz 左右,对应于
plot(t,x)
中看到的 16 秒周期。但这在计算上并没有那么快。 FFT是N*log(N)运算。
The Discrete Fourier Transform can give you the periodicity. A longer time window gives you more frequency resolution so I changed your
t
definition tot = linspace(0, 500, 2000)
.time domain http://img402.imageshack.us/img402/8775/timedomain.png (here's a link to the plot, it looks better on the hosting site).
You could do:
frequency domain http://img406.imageshack.us/img406/2696/freqdomain.png Plot link.
Looking at the graph, the first peak is at around 0.06 Hz, corresponding to the 16 second period seen in
plot(t,x)
.This isn't computationally that fast though. The FFT is N*log(N) operations.