Low pass filter design
7 views (last 30 days)
Show older comments
I need to design a low pass filter with a cutoff frequency of 50Hz. I am using the sptool in MATLAB to design the filter. How does the sampling frequency of the filter and the sampling frequency of the input signal to the filter affect the output response of the filter?Can somebody please help me with the specifications that should be applied to the filter so that the output waveform is optimum? There are many filters available and I do not have sufficient background to design.
0 Comments
Answers (3)
Jan Rubak
on 14 Feb 2011
Filter design is all about tradeoffs, so you need to choose the design method that best suits your needs. If this is for a student project, chances are that the nuanced differences between the various design methods do not really have great import for you (although linear phase in the passband is often an important requirement), and a good starting point would be an equiripple FIR filter where you specify the length, cutoff frequency, passband ripple and stopband attenuation.
The length of your filter should reflect your how stationary the input signal is, in general should be much less than the length of your time-series and preferably more than one cycle at the cut-off frequency (for 50Hz cutoff at 1000Hz sample rate, you're probably looking at something between N = 50 and 250).
Reasonable starting points for passband ripple and stopband attenuation are, say, 1dB and 60dB, respectively. But this is really something that you'd typically choose based on the characteristics of your data: what you consider signal, what you consider noise, how strong they tend to be relative to each other.
Try this:
FilterSpec = fdesign.lowpass('N,Fc,Ap,Ast',50,50,1,60,1000); % Or use the 'N,Fp,Ap,Ast' format if that's more applicable
disp(designmethods(FilterSpec)) % To verify that this specification is appropriate for the type of design method you want to use
FilterObj = design(FilterSpec,'equiripple');
fvtool(FilterObj) % To visually explore the spectral characteristics of your filter
If the transition band isn't narrow enough for your needs, then you can increase the length of the the filter, or relax the passband ripple or stopband attenuation constraints.
Once you're happy with your design, you can apply the filter to your time-series via any of:
FilteredSeries = FilterObj.filter(RawTimeSeries);
FilteredSeries = filter(FilterObj,RawTimeSeries);
FilteredSeries = filter(FilterObj.Numerator,1,RawTimeSeries);
FilteredSeries = conv(RawTimeSeries,FilterObj.Numerator,'valid');
The 3rd and 4th of these only work for FIR filters. You'll probably want to discard the first N values of the filtered series generated by the first three commands (the fourth command already does this because of the 'valid' flag).
0 Comments
See Also
Categories
Find more on Filter Design in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!