1D Gaussian Filter using FFT

6 次查看(过去 30 天)
SM
SM 2011-5-18
Hi I am trying to filter data(not periodic) represented by tanh profile.
My steps are -
signal: tanh (x)
ffts = fft(signal)
g = 1D Gaussian Filter normalised by its area
fftg = FFT(g)
fs = ffts.*fftg
s = real(ifft(fs))
But this is not giving the correct output.
What am I doing wrong?
Thanks in advance
SM

回答(3 个)

phani
phani 2011-5-18
dear SM i can suggest you one one of the possible way. the convolution in the time domain is same as the multiplication in the frequency domain. so design a filter using fdatool and obtain the coefficients and do convolution of your signal and the filter coefficients. and compare the ffts of both i.e. FFT without filtering and FFT with filtering. i think that may work.
  1 个评论
SM
SM 2011-5-18
Dear Phani
Thanks for your reply.
I do not want to use fdatool but use a simple gaussian profile like
g = sqrt(6/(pi*s^2))*exp(-6*x.^2/(s^2));
I tried convolution also in this way-
w = conv(S,g,'same');
I fo not get correct result. Do you think this is OK?
Regards
SM

请先登录,再进行评论。


Honglei Chen
Honglei Chen 2011-5-18
Hi SM,
From the code you posted here, my suspect is that you did not use enough points in your FFT to remove the aliasing. Note that ifft of product of fft is, in theory, the circular convolution so you have to use enough points to make it the same as linear convolution. Can you try to use 2*numel(g)-1 as number of FFT points in your snippet and see if it resolves the issue? The 'same' option in CONV merely returns the central part of the linear convolution, which is not the same as the circular convolution.
HTH,
Honglei

SM
SM 2011-5-19
Hi Honglei
Thanks for your reply. I am not sure if I got you correctly.
The filter g has less number of points than the signal s.
So I am kind of padding fft(g) to get the product fs = ffts.*fftg.
I think I am making a mistake there.
Please advise.
Regards
SM

类别

Help CenterFile Exchange 中查找有关 Frequency Transformations 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by