Smoothing and Filtering Data with FFT

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?

回答 (2 件)

Star Strider
Star Strider 2017 年 5 月 9 日

0 投票

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 件のコメント

Star Strider
Star Strider 2017 年 5 月 9 日
‘Now if i analize it, i can see that the noise is concentrate from 0Hz to 20Hz (apposimately) right?’
I will rely on you for that. I cannot tell.
Here is a prototype FIR highpass filter design with a passband frequency of 20 Hz (it will only pass frequencies greater than about 20 Hz) with a sampling frequency of 100 Hz:
Fs = 100;
hp_frq = [18 20];
mags = [0 1];
devs = [0.05 0.01];
[n,Wn,beta,ftype] = kaiserord(hp_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)
Experiment with it to get the result you want. You can get a ‘sharper’ cutoff (shorter transition region), however this creates a longer filter.
sbareben
sbareben 2017 年 5 月 10 日
編集済み: sbareben 2017 年 5 月 10 日
Thanks, i try the filter, i change the cutoff frequency, near small value to remove DC Components, for the signal post originally, i'll get this result:
Do you think that is correct?
If i integrate it, seems i can obtain good value.
But the amplitude of the velocity seems althrought that doesn'correspond to high peaks in the acceleration, and this descourage me, so i'm trying to apply an high-pass butter filter of 6th order. (Could be a good solution?)
Star Strider
Star Strider 2017 年 5 月 10 日
I cannot tell if that is correct, or what the best approach would be, because I do not know what you are doing.
The integration is essentially a low-pass filter.
sbareben
sbareben 2017 年 5 月 10 日
編集済み: sbareben 2017 年 5 月 10 日
I'm trying to integrate the signal, but if don't filter it right the velocity result is incorrect.
Star Strider
Star Strider 2017 年 5 月 10 日
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.)

サインインしてコメントする。

sbareben
sbareben 2017 年 5 月 9 日
編集済み: sbareben 2017 年 5 月 9 日

0 投票

Thanks, for the answer, so i adjust my fourier transform like this:
L = length(signal);
f = Fs*(0:(L/2))/L;
Y = fft(signal);
P2 = abs(Y/L);
P1 = P2(1:floor(L/2)+1);
P1(2:end-1) = 2*P1(2:end-1);
plot(f,P1)
title('Single-Sided Amplitude Spectrum of Data(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
Now if i analize it, i can see that the noise is concentrate from 0Hz to 20Hz (apposimately)right?
Now, i would to filter the signal, to doing that in accordance as you suggest and use a FIR filter, how can i use the frequency founded into FFT analysis to filter data? Sorry for the question, but i really don't know how to do it beacuse i'm not a filter expert, and before doing something i'll try to understand better.

質問済み:

2017 年 5 月 9 日

コメント済み:

2017 年 5 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by