% circconv.m
% usage: Y = circconv(X,h) 
% Performs circular convolution by the causal filter h on X.
% The result has the same size as X.
% It is assumed that length(h) <= length(X). 

function Y=circconv(X,h)
  Y = conv(X,h);
  m = length(X);
  n = length(Y);
  Y(1:n-m) = Y(1:(n-m))+Y((m+1):n);
  Y = Y(1:m);
  
                   
