File Exchange

image thumbnail

FFT filter - clean your signals and display results!

version (2.54 KB) by Shmuel Ben-Ezra
Perform Fourier transform, filter in frequency domain, reconstruct the signal.


Updated 16 Aug 2009

View License

The function introduces the implementation of fft and ifft in filtering and cleaning of signals.
The function plots
1. the original signal,
2. its transform,
3. the reconstructed (filtered) signal.
You can control the filtering by giving your parameters.
Comprehensive help is included (>>help fftf).
The code is extensively commented.

Comments and Ratings (25)

I got empty transform and filtered signal, needs help.

hafis radzi

how to declare the parameter?

elias GR

Aitor Arana

Awesome, Thanks

This is excellent!!! Thanks a lot

Worked immediately, very nice. Thanks Shmuel.
ps: thank you Craig Doolittle for your quick input on getting non-rescaled data.


Works very nicely and solved the problem with minor rectification.
Reconstructed signal has problem of scaling. It needs to multiplied by length of signal. After fft, it was divided by length, which need to nullify.
Suggestions(already given by others also):
1. Plotting can be option, default off.
2. band pass, high pass option can be added.
3. raw plots instead of normalized plot to compare with original.

Why not apply a low-pass filter instead of simply setting to 0 the spectral amplitudes above the cut-off frequency?
With your technique, the result might be erroneous due to aliasing.

Otherwise, nice function.



Suzie Mason

Thank you for sharing! Very useful and clearly written.


I noticed that the output signal is always plotted on a scale of -1 to +1. I take it this is always a normalized plot?

Moe Ring

Undefined function 'fftf' for input arguments of type 'double'.

I just wanted to use my signal... any suggestions?

This code is so good! I have learned a lot from you code and have simply changed it to have 3 filtering mode. Don't know how to update it in comment. Anyway, thanks for sharing this!

Fan D.Chen

Can This code be used as a bandpass filter?


Very nice and easy to use fft-implementation. I've used this extensively for my thesis. Thanks a lot!


Excellent code. For a mech eng, this is a godsend.


Works great!

Also made the change Craig made.


Well written code. The commenting on the lines is very much appreciated making it easier for the user to follow. Thank you very much!!


anybody help to run this code.

I changed line 56 from:
in order to return original scaling

This file saved me some time writing my own, thank you very much!

Very well written. Thanks a lot. It helped me so much.


included a screenshot

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux