function H = ImpRespMatrix(h, N);
% This function returns a matrix H that permits to easily find
% the output of the LTI system with impulse response h, when the
% input is a periodic signal with period N.
[ W, L ] = size(h);  
if W>1, h = h'; L = W; end; % just to make sure h is a row vector... 
% append zeros to h to obtain a length that is a multiple of N:
hpadded = [ h, zeros(1, ceil(L/N)*N-L) ];
hN = zeros(1, N); for k=0:ceil(L/N)-1, hN = hN + hpadded(k*N+1:(k+1)*N); end; 
H = zeros(N, N); for k=1:N,  H(k, :) = [ hN(k:-1:1), hN(N:-1:k+1) ]; end;
