MATLAB Answers

FIltering for multiple band of frequncies

274 views (last 30 days)
I have below two questions.
  1. I want to filter a signal with sampling 100Hz in range of 4-7Hz and 10-13Hz and 30-35Hz. I saw the bandpass function that says to filter seperating and concatenate the filtered signal. But I want to know if we could filter these 3 range of frequncies with any specific filter?
  2. What is bandpass or bandstop ripple and how to we choose the ripple ?

Accepted Answer

Star Strider
Star Strider on 6 Feb 2020
As much as I like elliptic filters, creating three of them and filtering them in parallel is simply not efficient. Multiband filters are much easier to implement as FIR filters.
Try a FIR filter such as this one:
Fs = 100; % Sampling Frequency (Hz)
fcuts = [3.5 4 7 7.5 9.5 10 13 13.5 29 30 35 36]; % Frequencies
mags = [0 1 0 1 0 1 0 ]; % Passbands & Stopbands
devs = [0.05 0.01 0.05 0.01 0.05 0.01 0.05]; % Tolerances
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,Fs); % Kaiser Window FIR Specification
n = n + rem(n,2);
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale'); % Filter Realisation
figure
freqz(hh,1,2^14,Fs)
set(subplot(2,1,1), 'XLim',[0 50]); % Zoom Frequency Axis
set(subplot(2,1,2), 'XLim',[0 50]); % Zoom Frequency Axis
Then use the filtfilt function to do the actual filtering:
signal_filtered = filtfilt(hh, 1, signal);
The Bode plot for this filter:
FIltering for multiple band of frequncies - 2020 02 06.png
  4 Comments
Star Strider
Star Strider on 8 Feb 2020
As always, my pleasure!
In the fir1 filters designed by kaiserord, all of that is in the code for the kaiserord function (see Algorithms for detaills). The stopband attenuation is 50 dB. The passband ripple is usually about 1 dB.
Other functions, such as firpmord and firpm are more flexible and permit more parameters to be specified in the design.
I chose kaiserord and fir1 for this because they are generally adequate in my experience, and preferable for efficient multi-band filters such as the one you requested.
There are many other options. See Digital Filter Design for a reference to all of them.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!