


cconv.m Circular convolution. Usage : y = cconv(x,h,k) x - input signal h - filter k - output hole in filter (k=0 if the filter is causal) Written by : Justin Romberg Created : 2/16/98, Revised : 5/1/2001


0001 % cconv.m 0002 % 0003 % Circular convolution. 0004 % Usage : y = cconv(x,h,k) 0005 % x - input signal 0006 % h - filter 0007 % k - output hole in filter (k=0 if the filter is causal) 0008 % 0009 % Written by : Justin Romberg 0010 % Created : 2/16/98, Revised : 5/1/2001 0011 0012 function y = cconv(x,h,k) 0013 0014 if (nargin == 2), k = 0; end 0015 0016 N = length(x); 0017 M = length(h); 0018 inds = mod([1:N 1:M-1]-1, N) + 1; 0019 y = cshift(conv2(x(inds), h, 'valid'),M-k-1,'r'); 0020 0021 % old code 0022 % 0023 %inds = mod([N-M+2+k:N 1:N 1:k]-1, N) + 1; 0024 %y = conv2(x(inds), h, 'valid');