Effacer les filtres
Effacer les filtres

1D Gaussian Filter using FFT

8 vues (au cours des 30 derniers jours)
SM
SM le 18 Mai 2011
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

Réponses (3)

phani
phani le 18 Mai 2011
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 commentaire
SM
SM le 18 Mai 2011
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

Connectez-vous pour commenter.


Honglei Chen
Honglei Chen le 18 Mai 2011
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 le 19 Mai 2011
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

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by