Filter a signal to obtain a smooth fft

24 views (last 30 days)
Hi,
I have a sequence of samples obtained in an accelerometer installed in a structure. If I do the fft of the signal, the natural frequency of the structure appears as a high peak in the fft graph.
I need to filter the accelerometer signal in order to obtain a smooth fft curve. If I use a bandstop filter to eliminate the natural frequency, all the frequency band dissapears and the curve has a deep valley.I want to eliminate only the peak to obtain a continuous distribution of frequencies.
Do you have any idea of how can I obtain this? Any advice will be great!
Lots of thanks for reading!

Accepted Answer

Wayne King
Wayne King on 27 Sep 2011
Maria, how about using a notch filter? I don't know what version of MATLAB you are running, but do you have the DSP System Toolbox, or the Filter Design Toolbox?
Fs = 1e3;
t = 0:1/Fs:1-(1/Fs);
x = cos(2*pi*100*t)+0.5*randn(size(t));
d = fdesign.notch('N,F0,Q,Ap',6,100,10,1,1000);
Hd = design(d);
% View notch filter magnitude response
fvtool(Hd)
% filter signal
y = filter(Hd,x);
plot(psd(spectrum.periodogram,y,'Fs',Fs,'NFFT',length(y)))
figure;
plot(psd(spectrum.periodogram,x,'Fs',Fs,'NFFT',length(y)))
Wayne
  3 Comments
Wayne King
Wayne King on 27 Sep 2011
Hi Maria, yes, you can adjust the depth of the notch you obtain with the notch filter. Here is how you can get 30 dB of attenuation in the notch at 100 Hz.
d = fdesign.notch('N,F0,Q,Ast',6,100,30,30,1000);
Hd = design(d);
fvtool(Hd)
MariaLA
MariaLA on 27 Sep 2011
You are right.I've been trying the filter with different factors and the result seems valid.
Lots of thanks, Wayne.

Sign in to comment.

More Answers (1)

Wayne King
Wayne King on 23 Sep 2011
Hi, You don't need to filter to produce a smooth fft(). Using a fft() directly on a time series and plotting the magnitude squared of the DFT coefficients is proportional to the periodogram. The periodogram is a low-degree-of-freedom estimate of the true power spectral density. The periodogram has great resolution, but suffers from high variance and inconsistency.
You can smooth the periodogram in a number of ways. You will lose some resolution but you may find the trade off acceptable.
You can obtain a smoother plot by using a Welch estimate or multitaper estimate
Fs = 1e3;
t = 0:.001:1-0.001;
x = cos(2*pi*100*t)+randn(size(t));
% compare
plot(psd(spectrum.periodogram,x,'NFFT',length(x),'Fs',1e3));
%with
figure;
hwelch = spectrum.welch;
hwelch.SegmentLength = 100;
plot(psd(hwelch,x,'NFFT',length(x),'Fs',1e3));
% or
figure;
plot(psd(spectrum.mtm,x,'NFFT',length(x),'Fs',1e3));
Note that you do lose frequency resolution with both the Welch and multitaper estimators --- there is no free lunch.
  3 Comments
Wayne King
Wayne King on 26 Sep 2011
Yes, I do.
Do you want to just eliminate a peak at 100 Hz, or really a band of frequencies around 100 Hz?
MariaLA
MariaLA on 27 Sep 2011
I want to eliminate only the peak of resonance frequency, but to configure the bandstop filter I had to define a band of frequencies around the peak.
A comment: In the code above I made a mistake
Wn(1)=90/Fn or Wn(1)=95/Fn for example, not 900

Sign in to comment.

Categories

Find more on Get Started with Signal Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!