2

I have two signals that I want to synchronize (find the time lag). I already did this using the "ccf" function and finding the maximum, following this post:

Finding lag at which cross correlation is maximum ccf( )

I though I'd have to do something like

fft1 <- fft(my.vector1)
fft2 <- fft(my.vector2)
ccf(fft1, fft2, lag.max = 6000, plot = FALSE)

However, for efficiency reasons, I would like to implement the cross-correlation with the fast fourier transform (FFT), as suggested in other posts. I have many tests with 300.000 samples (1.5 minutes sampled at 2000Hz), and a maximum lag of -3 to 3 seconds.

Any hints on how to do that in R?

I know the fft and ccf functions, but don't know how to integrate them.

4

1 回答 1

1

两个复函数的互相关等于一个函数的卷积和另一个函数的复共轭:

互相关和卷积

由于convolve R 中的函数已经使用了快速傅立叶变换,因此您所要做的就是:

convolve(my.vector1, my.vector2)

最大滞后可以通过以下方式找到:

which.max(convolve(my.vector1,my.vector2))
于 2014-12-31T19:06:56.813 回答