DSPRelated.com
Code

Circular Convolution Matrix

February 1, 2011 Coded in Matlab

Makes a circular convolution matrix, very useful when working with OFDM.

function HC = convmtx_circ(h, N);
% CONVMTX_CIRC Circular Convolution Matrix.
%    CONVMTX_CIRC(h,N) returns the circular convolution matrix for vector h.
%    h must be a column vector. If X is a column vector of length N,
%    then CONVMTX_CIRC(h,N)*X is the same as the circular convolution h * X.
%
% by Danilo Zanatta - 01.02.2011

h = h(:);
Nh = length(h);
Nc = N + Nh - 1;

if N < Nh,
    error('The circular convolution matrix size must be greater or equal the channel length');
end

H = convmtx(h,N);

HC = H(1:N, 1:N);
HC(1:(Nh-1), 1:N) = HC(1:(Nh-1), 1:N) + H((N+1):Nc, 1:N);

return