Package: dsp
Variable bandwidth FIR filter
The VariableBandwidthFIRFilter
object filters
each channel of the input using FIR filter implementations. It does
so while having the capability of tuning the bandwidth. This filter
supports double and single precision inputs.
To filter each channel of the input:
Define and set up your variable bandwidth FIR filter. See Construction.
Call step
to filter
each channel of the input according to the properties of dsp.VariableBandwidthFIRFilter
.
The behavior of step
is specific to each object in
the toolbox.
Note:
Starting in R2016b, instead of using the 
HFIR = dsp.VariableBandwidthFIRFilter
returns
a System object, HFIR
, which independently filters
each channel of the input over successive calls to the step
method.
This System object uses a specified FIR filter implementation.
The filter's cutoff frequency may be tuned during the filtering
operation. The variable bandwidth FIR filter is designed using the
window method.
HFIR = dsp.VariableBandwidthFIRFilter('
returns a variable bandwidth FIR filter System object, PropertyName
',PropertyValue
,
...)HFIR
,
with each property set to the specified value. You can specify additional
namevalue pair arguments in any order as (Name1,Value1,...,NameN,ValueN
).

Input sample rate Specify the sampling rate of the input in Hertz as a finite numeric scalar. The default is 44.1 kHz. This property is nontunable. 

Filter type Specify the type of the filter as one of 

FIR filter order Specify the order of the FIR filter as a positive integer scalar. The default is 30. This property is nontunable. 

Window function Specify the window function used to design the FIR filter as
one of 

Kaiser window parameter Specify the Kaiser window parameter as a real scalar. This property
applies when you set the window property to 

Filter cutoff frequency Specify the filter cutoff frequency in Hz as a real, positive
scalar, smaller than the 

Filter center frequency Specify the filter center frequency in Hz as a real, positive
scalar, smaller than 

Filter bandwidth Specify the filter bandwidth in Hertz as a real, positive scalar,
smaller than 

Chebyshev window sidelobe attenuation Specify the Chebyshev window attenuation as a real, positive
scalar in decibels (dB). This property applies if you set the 
clone  Create variable bandwidth FIR filter with same property values 
isLocked  Locked status for input attributes and nontunable properties 
release  Allow property value and input characteristics changes 
reset  Reset internal states of variable bandwidth FIR filter 
step  Filter signal using variable bandwidth algorithm 
All transformations assume a lowpass filter of length 2N+1.
Consider an ideal lowpass brickwall filter with normalized cutoff frequency ω_{c1}. By taking the inverse Discrete Fourier Transform of the ideal frequency response, and clipping the resulting sequence to length 2N+1, the impulse response is:
$$\begin{array}{l}forn=0\\ {h}_{LP}(n)=\frac{{\omega}_{c}}{\pi}.w(0)\\ for\text{1}\le \text{n}\le \text{N}\\ {h}_{LP}(n)=\frac{\mathrm{sin}({\omega}_{c}n)}{\pi n}.w(n)\end{array}$$
where w(n) is the window vector. The lowpass filter coefficients are tuned to a new cutoff frequency ω_{c2} as follows:
$$\begin{array}{l}for\text{}n=0\\ {h}_{LP}(n)=\frac{{\omega}_{c2}}{\pi}.\omega (0)\\ for\text{}1\text{}\le \text{}\leftn\right\text{}\le \text{}N\\ {h}_{LP}(n)=\frac{\mathrm{sin}({\omega}_{c2}n)}{\pi n}.\omega (n)\end{array}$$
There is no need to recompute the window every time you tune the cutoff frequency.
Assuming a lowpass filter with normalized 6–dB cutoff frequency ω_{c}, a highpass filter with the same cutoff frequency can be obtained by taking the complementary of the lowpass frequency response: H_{HP}(e^{jω}) = 1 — H_{LP}(e^{jω})
Taking the inverse discrete Fourier transform of the above response, we get the following highpass filter coefficients:
$$\begin{array}{l}for\text{}n=0\\ {h}_{hp}(n)=1{h}_{LP}(n)\\ for\text{}1\le \text{}\leftn\right\text{}\le \text{}N\\ {h}_{hp}(n)={h}_{LP}(n)\end{array}$$
A bandpass filtered centered at frequency ω_{0} can be obtained by shifting the lowpass response:
H_{BP}(e^{jω}) = H_{LP}(e^{j(ω–ω0})) + H_{LP}(e^{j(ω–ω0)})
The bandwidth of the resulting bandpass filter is 2ω_{c}, as measured between the two cutoff frequencies of the bandpass filter. The equivalent bandpass filter coefficients are then:
$$\begin{array}{l}{h}_{BP}(n)=({e}^{j{\omega}_{0}n}+{e}^{j{\omega}_{0}n}){h}_{LP}(n)\\ \text{whichcanbewrittenas:}\\ {h}_{BP}(n)=2\mathrm{cos}({\omega}_{0}n){h}_{LP}(n)\end{array}$$
We can transform a lowpass filter to a bandstop filter by combining the highpass and bandpass transformations. That is, first make the filter bandpass by shifting the lowpass response, and then invert in to get a bandstop response centered at ω_{0}.
H_{BS}(e^{jω}) = 1 – (H_{LP}(e^{j(ω–ω0)}) + H_{LP}(e^{j(ω+ω0)}))
This yields the following coefficients:
$$\begin{array}{l}for\text{}n=0\\ {h}_{BS}(n)=12\mathrm{cos}({\omega}_{0}n){h}_{LP}(n)\\ for\text{}1\le \text{}\leftn\right\text{}\le \text{}N\\ {h}_{BS}(n)=2\mathrm{cos}({\omega}_{0}n){h}_{LP}(n)\end{array}$$
The transformations highlighted above can be combined to transform a lowpass filter to a lowpass, highpass, bandpass or bandstop filter with arbitrary cutoffs.
For example, to transform a lowpass filter with cutoff ω_{c1} to a highpass with cutoff ω_{c2}, you first apply the lowpasstolowpass transformation to get a lowpass filter with cutoff ω_{c2}, and then apply the lowpasstohighpass transformation to get the highpass with cutoff ω_{c2}.
To get a bandpass filter with center frequency ω_{0} and bandwidth β, we first apply the lowpasstolowpass transformation to go from a lowpass with cutoff ω_{c} to a lowpass with cutoff β/2, and then apply the lowpasstobandpass transformation to get the desired bandpass filter. The same approach can be applied to a bandstop filter.
[1] Jarske, P.,Y. Neuvo, and S. K. Mitra, "A simple approach to the design of linear phase FIR digital filters with variable characteristics." Signal Processing. Vol. 14, Issue 4, June 1988, pp. 313326.
dsp.AllpoleFilter
 dsp.BiquadFilter
 dsp.FIRFilter
 dsp.IIRFilter
 dsp.VariableBandwidthIIRFilter
 Variable Bandwidth FIR Filter  Variable Bandwidth IIR Filter