% circconv.m
% usage: Y = circconv(X,h) 
% Performs circular convolution by h on X, the result has the same size as X.
% It is assumed that length(h) <= length(X). 
% The result is the same as zero-padding h out to the length of X, 
% and then computing the convolution X*h.

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);
  
                   
