Convolution in frequency domain (NOT CONVOLUTION IN TIME DOMAIN)

I know there are two theorem:
  1. convolution in time domain equals multiplication in frequency domain;
  2. multiplication in time domain equals convolution in frequency domain;
I am confused with the implementation with the 2nd in MATLAB. Here is my codes:
a = 1:5;
b = a+3;
A = fft(a);
B = fft(b);
c = a .* b
ans =
4 10 18 28 40
D = conv(A, B);
d = real(ifft(D))
d =
Columns 1 through 5
11.111 50.544 26.081 58.919 39.694
Columns 6 through 9
73.642 52.666 95.071 42.27
so my quesition is why the "a.*b" is not the same with "real(ifft(D))", is somewhere wrong? I know in the 1st theorem, the Nfft should be length(A)+length(B)-1, however, it seems not work here.
Any help will be thanks!

 Réponse acceptée

Matt J
Matt J le 20 Jan 2013
Cyclic convolution is the dual of multiplication when dealing with discrete fourier transforms. You are doing linear convolution.

4 commentaires

chen xy
chen xy le 20 Jan 2013
Modifié(e) : Image Analyst le 20 Jan 2013
Thanks for answer, and what's the difference between the cyclic and linear convolution in implementation ? For the above codes, how should I rectify ?
One way to implement cyclic convolution is as a matrix multiplication, using this
For you, it would be
N=length(A);
CirculantMatrix = interpMatrix(A,1,N,1,'circ');
C=CirculantMatrix*B(:); %cyclic convolution
c=ifft(C,'symmetric').'/N
c =
4.0000 10.0000 18.0000 28.0000 40.0000
It works well, thx a lot!
Hi guys
How can I do the same for two matrices of the same size? say:
x = [3 5 4; 7 6 1; -1 2 0];
y = [2 7 1; 2 -3 2; 5 6 9];
how can I get the same results as x.*y using convolution of the fft2 of these two matrices?
Thanks in advance

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by