how to evaluate a convolution integral by fast fourier transform

5 visualizaciones (últimos 30 días)
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))

Respuesta aceptada

David Young
David Young el 3 de Jul. de 2015
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 comentario
bazrafshan88@gmail.com
bazrafshan88@gmail.com el 6 de Jul. de 2015
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by