Feed on
Posts
Comments

here’s an easy way to do low-pass signal filtering in matlab:

function [s_data_v] = fftsmooth(data_v,freq_n)
% use fft low pass filter to smoothen out a signal

fft_data_v = fft(data_v);
s_fft_data_v = zeros(1,length(data_v));
s_fft_data_v(1:freq_n) = fft_data_v(1:freq_n);
s_fft_data_v(end-freq_n:end) = fft_data_v(end-freq_n:end);
s_data_v = real(ifft(s_fft_data_v));


Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

4 Responses to “use fast fourier transform (fft) to perform low-pass filtering”

  1. on 13 Dec 2009 at 10:05 pm Spencer

    A few suggestions – cutting off frequencies like that effectively multiplies by a rectangular window, which will smear a lot of content back in the time domain. It’s for this reason that low pass filter design usually multiplies the ideal lpf in the frequency domain (i.e., rect window cutoff at the proper frequency) with a hann window or something similar. Check out this thread http://www.dsprelated.com/showmessage/42364/1.php for some more in depth thoughts on the subject.

    Also, the “real” would not be necessary if you ensure conjugate symmetry before the ifft(). For even N, keep the first N/2+1 elements and set the last N/2-1 to conj(fliplr(s_fft_data_v(2:N/2))). I think that would be the correct syntax in your case, but you probably want to check the details to make sure.

    I do hope these ideas are helpful and apologies if I’m pointing out something you’re already aware of and intentionally omitting!

  2. on 16 Aug 2011 at 6:09 am sh

    Could you please explain more about what you wrote and how does it work?
    I used it and the result is good but i don’t know how does it work.

  3. on 24 Sep 2013 at 8:04 pm MuKuT

    Hello, would you please add some explanation so that it could be easier for us who doesn’t have vast knowledge of matlab.

    I have 20k voltage output at 1ms sampling rate. I already done fft in matlab now now I want to apply low pass filter with cut off freq=400hz. How can I do it?

    Thanks

  4. on 20 Apr 2015 at 1:44 pm purvi

    I tried to use this code to demodulate DSBSC AM signal(i.e.,using coherent detector),but the demodulated signal i am getting is not smooth.It has ripples in it.Plz can you help?

Did I get this wrong? Let me know!

Trackback URI | Comments RSS

More blogs about http://desk.stinkpot.org:8080/tricks.