MATLAB: Is there a function that calculates circular cross-correlation of sequences

convolutionSignal Processing Toolbox

I know that XCORR calculates linear cross-correlation function estimates, but I wonder if there is a function that calculates circular correlation.

Best Answer

  • If you have the Signal Processing Toolbox, you can use the CCONV function to calculate the circular cross-correlation of two sequences.
    The following example from the documentation for CCONV (link below) calculates a circular cross-correlation of two sequences:
    a = [1 2 2 1]+1i;
    b = [1 3 4 1]-2*1i;
    c = cconv(a,conj(fliplr(b)),7);
    https://www.mathworks.com/help/signal/ref/cconv.html#buzbj12
    Note that this function was introduced in R2007a. For previous versions, you would need to implement a custom function in order to compute the circular cross-correlation.
    If you do not have the Signal Processing Toolbox, you could also calculate the circular cross-correlation using the FFT function using the following syntax:
    circcorr_ab = ifft(fft(a).*conj(fft(b)));