Smoothing and Filtering Data with FFT
24 views (last 30 days)
Show older comments
i've a many file each one include a signal, into the file the sample are saved every 0.01s (100Hz), the problem is that my signal is composed from much noise, i made the FFT of the signal, i take the magnitude of it, now my question is, how can i made filter or usign FFT to smoothing it? beacuse i'm interesting only to the value of signal that are >= 2 more or less, the rest that is tall i'm interested to smoothing, beacuse than i need to integrate the filtered signal. And i need to create an automated system to filter the signal, that is equal to each file. But i'don't know how to filter the data with FFT.
This is the original signal:

SO i did the FFT of this signal:
fft_value = fft(SignalIn);
magnitude = abs(fft_value);
frequency = 100*(0:(numel(magnitude)-1))/numel(magnitude);
plot(frequency, magnitude);
And this is the magnitude.

First of all, the calculate of the magnitude is correct?
If i analize it, i take into consideration only the value from 0 to 50Hz, so the half of the plot, than my noise is concentrate, around the high amplitude peaks right? For example between 1Hz to 20Hz? How can i filter into this frequency for example and get a clean signal that smoothed low components, and don't change the high signal components?
0 Comments
Answers (2)
Star Strider
on 9 May 2017
Your Fourier transform calculation is incorrect. See the documentation in this version fft (link), especially the code between the first (top) two plot figures.
Second, you can do filtering in the frequency domain with the Signal Processing Toolbox fftfilt (link) function. You will have to experiment with the FIR filters to get the result you want.
Here is prototype code for a bandstop filter to get you started with your FIR filter design (that you will need in order to use fftfilt):
Fs = 256;
notch_frq = [45 48 50 52];
mags = [1 0 1];
devs = [0.05 0.01 0.05];
[n,Wn,beta,ftype] = kaiserord(notch_frq,mags,devs,Fs);
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'scale');
figure(1)
freqz(hh, 1, 2^17, Fs)
See the documentation for the various functions to understand how to design the filter you want.
5 Comments
Star Strider
on 10 May 2017
I cannot see anything in the signal you plotted that suggests specific peaks in the spectrum. It has significant broadband noise that you can probably only eliminate with a wavelet filter in the time domain before processing it further. There are examples in the Wavelet Toolbox on this. (I do not have sufficient experience with wavelets to help you with this.)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

