根据卷积定理,时域的卷积是fft域的乘积。使用正确的零填充,它可以工作:
% convolution in time domain
a = [1 2 3];
b = [4 5 6];
c = conv(a,b);
a_padded=[a 0 0]; b_padded=[b 0 0];
c_bis=ifft(fft(a_padded).*fft(b_padded));
% we do find c_bis=c
然而,这个定理也应该反过来工作,时域中的乘积是 fft 域中的卷积。我不明白这部分:
d = a.*b;
D=conv(fft(a_padded),fft(b_padded));
d_bis=ifft(D);
它给出了 d_bis 的复向量。 如何使用频域中的卷积来反转在时域中生成的逐点乘积?
最佳答案
有趣的问题!
错误(虽然是一个微妙的错误)是当你说
A product in the time domain is a convolution in the FFT domain
傅里叶变换也是如此。用Discrete Fourier transforms (DFT,或 FFT),correct formulation是
A product in the time domain is a circular convolution in the FFT domain, divided by the sequence length
所以你必须在你的d_bis
计算中改变这个:
- 使用循环卷积,而不是卷积;
- 除以序列长度;
- 不要应用填充。
如果您有信号处理工具箱,您可以使用 cconv
计算循环卷积:
N = length(a);
D = cconv(fft(a),fft(b), N)/N;
d_bis=ifft(D); %// now this equals d
为了确保,correct formulation在第一种情况下(时域卷积给出频域乘积)还涉及循环卷积:
A circular convolution in the time domain is a product in the FFT domain
(在这种情况下不除以序列长度)
但是由于您在时域中填充了零,正常卷积和循环卷积之间的差异消失了,您得到了正确的结果。没有填充,它将是:
c = cconv(a, b, N);
c_bis=ifft(fft(a).*fft(b)); %// this equals c
关于matlab - 带 fft 的点积,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21865918/