how to evaluate a convolution integral by fast fourier transform

2 次查看(过去 30 天)
I need to evaluate a convolution integral by fft. Therefore, I have read somewhere in a paper to first zero-pad two multiplying functions and wrap around one of them. Then, an element-by-element multiplication and inverse transforming back to the spacial domain and then removing the elements corresponding to the added zeros will solve the problem. To give it a try, I started with a simple example. Consider f(x)=1 (for -1<x<1) and 0 (elsewhere). Also, g(x)=1-x.^2 (for -1<x<1) and 0 (elsewhere). I have calculated the convolution integral analytically to compare with my code results. However, my code does not provide acceptable results especially on boundaries. Also, I don't think I know and understand zero-padding and wrapping around order. Can anyone help me with this, please? Here is the simple code I have written:
clc
clear all
% the analytical result
d=[...
-0.6667
-0.2678
0.0868
0.3970
0.6630
0.8846
1.0619
1.1948
1.2835
1.3278
1.3278
1.2835
1.1948
1.0619
0.8846
0.6630
0.3970
0.0868
-0.2678
-0.6667];
hold on
plot(linspace(-1,1,20)',d,'o')
N=pow2(10);
dx=2/N;
x=linspace(-1,1,N);
x=x';
f=[1-x.^2;zeros(N,1)];
Ff=fft(f);
g=[ones(N,1);zeros(N,1)];
Fg=fft(g);
FG=Ff.*Fg;
fg=2/N*ifft(FG);
plot(x,fg(N/2+1:3/2*N))

采纳的回答

David Young
David Young 2015-7-3
Correct zero-padding to use the FFT for 1-D or 2-D convolutions is implemented in my FEX submission 2-D convolution using the FFT.
  1 个评论
bazrafshan88@gmail.com
Thank you David
But your code doesn't provide the accurate results, either. If you perform your conv_fft2 command in my simple example, you will see the difference.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by