I am trying to calculate autocorrelation using fft and xcorr and plot the grafhic with both cases.

autocorr_b=ifft( fft(signal_1,N1) .* conj(fft(signal_1,N1))); 
plot(x1, autocorr_a, x1, autocorr_b)

What is wrong?

  • $\begingroup$ Welcome to DSP.SE! Why are you asking "What is wrong?" there doesn't appear to be any information in your question as to what you think is wrong. Please edit your question to add this information. $\endgroup$
    – Peter K.
    Nov 17 '15 at 13:15

Matlabs xcorr() command performs linear correlation, whereas the FFT method you employ performs circular correlation, so there is time-aliasing in the same way as with frequency domain convolution.

You can simulate linear convolution in the frequency domain by sufficiently zero-padding your signal with N-1 zeros, where N is the length of your signal vector, before performing the FFT.


Not the answer you're looking for? Browse other questions tagged or ask your own question.