简体   繁体   中英

why convolution of x and y is different ifft(fft(x)xfft(y))?

I know that convolution of x and y in time domain is equal to fft(x) times by fft(y) in frequency domain. so I tried simple example using matlab as below.

xn=[1,2,3,4];
yn=[4,3,2,1];
zn=conv(xn,yn);

znr=ifft(fft(xn).*fft(yn));

and I got the result as below.

zn = 4 11 20 30 20 11 4 znr = 24 22 24 30

I wonder why zn is not equal to znr. Anyone who knows why pls explain.

Specifying the transform length when taking the fft() to configure the solution in the way you want may be a solution. Since typically the result of convolution has a length that is equal to the sum of the two signals convolved subtract 1 we can then set the Transform_Length to 7 in this case.

xn = [1,2,3,4];
yn = [4,3,2,1];
zn = conv(xn,yn);

Transform_Length = length(xn) + length(yn) - 1;
znr = ifft(fft(xn,Transform_Length).*fft(yn,Transform_Length));

zn
znr

Result:

卷积结果

Ran using MATLAB R2019b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM