# Implementing Frequency Domain Convolution in MATLAB (Convolution Theorem)

I'm trying to prove convolution in time domain is same as multiplication in frequency domain but I'm not getting the same answer in matlab.

Here is the code:

• multiplication of DFTs is circular convolution, not the linear one. Solution 1 : Try cconv : cconv(a,b) Solution 2 : Try adding cyclic prefix to a for example. aa=[a a]; conv(aa,b); The result is ifft(x.*y) from the end of cyclic prefix, in this case since the index 6. Jul 27, 2017 at 7:06

You need to set the length as well in your fft command. The two signals are of length $5$ and their convolution is of length $5+5-1=9$. So use this instead:

a=[1 2 3 4 5];
b=[6 7 8 9 10];
x=fft(a,9);
y=fft(b,9);
ifft(x.*y)

ans =

Columns 1 through 8

6.0000   19.0000   40.0000   70.0000  110.0000  114.0000  106.0000   85.0000

Column 9

50.0000

conv(a,b)
ans =

6    19    40    70   110   114   106    85    50

• Thanks a lot man I've been struggling a lot for this.No one has even asked any question regarding this. Jul 27, 2017 at 7:13