Ankara
Ankara

Reputation: 402

Autcorrelation Via FFT and Zero Padding MATLAB

I would like to understand conceptually why when calculating the Autocorrelation Function of a vector x via fft, the best way is to zero padding in the way

nFFT = 2^(nextpow2(length(x))+1); 

% nFFT = 2*length(x) will do it as well

F = fft(x-mean(x),nFFT);

and not, for instance

nFFT = 2^(nextpow2(length(y)));

Why do the way we pad the vector influence so much the approximation of the Autocorrelation Function?

Thank you.

Upvotes: 1

Views: 759

Answers (1)

hotpaw2
hotpaw2

Reputation: 70693

If you don't zero pad enough (to 2X or more than the original length), an FFT fast convolution correlation produces a circular autocorrelation, not a linear autocorrelation, which is usually what is desired.

Upvotes: 4

Related Questions