Skip to Main Content Skip to Search
Product Documentation

cconv - Modulo-N circular convolution

Syntax

c=cconv(a,b,n)

Description

Circular convolution is used to convolve two discrete Fourier transform (DFT) sequences. For very long sequences, circular convolution may be faster than linear convolution.

c = cconv(a,b,n) circularly convolves vectors a and b. n is the length of the resulting vector. If you omit n, it defaults to length(a)+length(B)-1. When n = length(a)+length(B)-1, the circular convolution is equivalent to the linear convolution computed with conv. You can also use cconv to compute the circular cross-correlation of two sequences (see the example below).

Examples

The following example calculates a modulo-4 circular convolution.

a = [2 1 2 1];
b = [1 2 3 4];
c = cconv(a,b,4)
% Returns
% c =
%    14    16    14    16  

The following example compares a circular correlation, where n uses the default value, and a linear convolution. The resulting norm is a value that is virtually zero, which shows that the two convolutions produce virtually the same result.

a = [1 2 -1 1];
b = [1 1 2 1 2 2 1 1];
c = cconv(a,b) 					% Circular convolution
cref = conv(a,b)				% Linear convolution
norm(c-cref)	 

The following example uses cconv to compute the circular cross-correlation of two sequences. The result is compared to the cross-correlation computed using xcorr.

a = [1 2 2 1]+1i;
b = [1 3 4 1]-2*1i;
c = cconv(a,conj(fliplr(b)),7);	% Compute using cconv
cref = xcorr(a,b);						% Compute using xcorr
norm(c-cref)

References

[1] Orfanidis, S.J., Introduction to Signal Processing, Englewood Cliffs, NJ: Prentice-Hall, Inc., 1996. pp. 524–529.

See Also

conv

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS