# Enforcing size to match Convolution using 'same' property & Enforcing Circulant Matrix (Like DFT Based Convolution)

The original problem was from this link about coding de-noising an audio signal.

Because my reputation points disabled me to comment, I have to ask a separate question here.

I don't quite understand the codes about formulating a circulant matrix.

% Enforcing size to match Convolution using 'same' property
mBlurKernel     = mBlurKernel(1:numSamples, :);
mGradientKernel = mGradientKernel(1:numSamples, :);
% Enforcing Circulant Matrix (Like DFT Based Convolution)
mBlurKernel(1, (end - 3):end) = vBlurKernel(1:4);
mBlurKernel(2, (end - 2):end) = vBlurKernel(1:3);
mBlurKernel(3, (end - 1):end) = vBlurKernel(1:2);
mBlurKernel(4, (end - 0):end) = vBlurKernel(1:1);
"


What's the meaningfulness of doing the following steps?

mBlurKernel     = mBlurKernel(1:numSamples, :);
mGradientKernel = mGradientKernel(1:numSamples, :);


Originally, I thought it was to match the matrix dimension of both mBlurKernel and mGradientKernel.

So I tried the following code.

h = 10;
a = [1 2 3 4 5];
b = [1 2];
A1 = convmtx(a, h);
A2 = convmtx(b, h);
size(A1) = 10 14
size(A2) = 10 11


Next, I tried to imitate the following steps:

A3 = A1(1:h, :);
A4 = A2(1:h, :);


It turned out that nothing happen to A3 and A4. It seems that A3 and A4 are the same as A1 and A2 respectively.

In addition, I don't understand the following code:

% Enforcing size to match Convolution using 'same' property
mBlurKernel     = mBlurKernel(1:numSamples, :);
mGradientKernel = mGradientKernel(1:numSamples, :);
% Enforcing Circulant Matrix (Like DFT Based Convolution)
mBlurKernel(1, (end - 3):end) = vBlurKernel(1:4);
mBlurKernel(2, (end - 2):end) = vBlurKernel(1:3);
mBlurKernel(3, (end - 1):end) = vBlurKernel(1:2);
mBlurKernel(4, (end - 0):end) = vBlurKernel(1:1);


Why must I do so in order to enforce a circulant matrix? Is there another way for me to enforce a circulant matrix?

I'll appreciate if someone could clarify my doubts.

• I understand the codes now. Still in the progress of figuring out the other part. {mBlurKernel = mBlurKernel(1:numSamples, :); mGradientKernel = mGradientKernel(1:numSamples, :);} – user42268 Oct 29 '15 at 4:56
• The periodic/circulant matrix seems incorrect – user42268 Oct 29 '15 at 19:48