필터 지우기
필터 지우기

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
bazrafshan88@gmail.com 2015년 7월 6일
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