Secondorder tunable notching and peaking IIR filter
The NotchPeakFilter
object filters each channel
of the input using IIR filter implementation.
To filter each channel of the input:
Define and set up your NotchPeak filter. See Construction.
Call step
to filter each channel
of the input according to the properties of dsp.NotchPeakFilter
.
The behavior of step
is specific to each object in
the toolbox.
Starting in R2016b, instead of using the step
method
to perform the operation defined by the System
object™, you can
call the object with arguments, as if it were a function. For example, y
= step(obj,x)
and y = obj(x)
perform
equivalent operations.
npFilter = dsp.NotchPeakFilter
returns
a secondorder notching and peaking IIR filter which independently
filters each channel of the input over time, using a specified center
frequency and 3 dB bandwidth. Both of these properties are specified
in Hz and are tunable. Both of these values must be scalars between 0
and
half the sample rate.
npFilter = dsp.NotchPeakFilter('
returns a notch filter with each specified property
name set to the specified value. You can specify additional namevalue
pair arguments in any order as PropertyName
',PropertyValue
,
...)(Name1,Value1,...,NameN,ValueN)
.
npFilter = dsp.NotchPeakFilter('specification','Quality
factor and center frequency')
specifies the quality factor
(Q factor) of the notch or peak filter instead of the 3
dB
bandwidth. The Q factor is defined as the center frequency divided
by the bandwidth. A higher Q factor corresponds to a narrower notch
or peak. The Q factor should be a scalar value greater than 0. The
Q factor is tunable.
npFilter = dsp.NotchPeakFilter('Specification','Coefficients')
specifies
the coefficient values that affect bandwidth and center frequency
directly, rather than specifying the design parameters in Hz. This
removes the trigonometry calculations involved when the properties
are tuned. The CenterFrequencyCoefficients
should
be a scalar between 1
and 1
,
with 1
corresponding to 0
Hz
and 1
corresponding to the Nyquist frequency. The BandwidthCoefficient
should
be a scalar between 1
and 1
,
with 1
corresponding to the largest 3
dB
bandwidth and 1
corresponding to the smallest 3
dB
bandwidth. Both coefficient values are tunable.

Filter specification Set the specification as one of 

3 dB bandwidth Specify the filter’s 

Notch or Peak center frequency Specify the filter’s center frequency (for both the notch
and the peak) as a finite positive numeric scalar in Hertz. This property
is applicable only if 

Quality factor for notch or peak filter Specify the quality factor (Q factor) for both the notch and
the peak filters. The Q factor is defined as the center frequency
divided by the bandwidth. This property is applicable only if 

Sample rate of input Specify the sample rate of the input in Hertz as a finite numeric
scalar. The default is 

Bandwidth coefficient Specify the value that determines the filter’s 

Center frequency coefficient Specify the coefficient that determines the filter’s
center frequency as a finite numeric scalar between 
getBandwidth  Get 3 dB bandwidth 
getCenterFrequency  Get center frequency 
getOctaveBandwidth  Bandwidth in number of octaves 
getQualityFactor  Get quality factor 
reset  Reset the internal states of notch or peak filter 
step  Process input using the notch or peak filter algorithm 
tf  Transfer function 
Common to All System Objects  

release  Allow System object property value changes 
The design equations for this filter are:
$$H(z)=(1b)\frac{1{z}^{2}}{12b\mathrm{cos}{w}_{0}{z}^{1}+(2b1){z}^{2}}$$
The previous equation is for peak filter, and the following equation is for notch filter.
$$H(z)=b\frac{12\mathrm{cos}{w}_{0}{z}^{1}+{z}^{2}}{12b\mathrm{cos}{w}_{0}{z}^{1}+(2b1){z}^{2}}$$
With
$$b=\frac{1}{1+\mathrm{tan}(\Delta w/2)}$$
$$\begin{array}{l}{H}_{notch}(z)+{H}_{peak}(z)=1\\ \text{theycanbewrittenas:}\\ {H}_{peak}(z)=\frac{1}{2}\left[1A(z)\right]\\ {H}_{notch}(z)=\frac{1}{2}\left[1+A(z)\right]\\ {\text{whereA(z)isa2}}^{\text{nd}}\text{orderallpassfilter}\text{.}\\ A(z)=\frac{{a}_{2}+{a}_{1}{z}^{1}+{z}^{2}}{1+{a}_{1}{z}^{1}+{a}_{2}{z}^{2}}\\ \text{and}\\ {a}_{1}=2b\mathrm{cos}{\omega}_{0}\\ {a}_{2}=2b1\end{array}$$
The filter is implemented as follows:
where
$$\begin{array}{l}{G}_{3dB}={a}_{2}=2b1\\ {G}_{cf}=\frac{{a}_{1}{a}_{1}{a}_{2}}{1{a}_{2}{}^{2}}=\mathrm{cos}{w}_{0}\end{array}$$
Notice that G_{cf} depends only on the center frequency, and G_{3dB} depends only on the 3 dB bandwidth.
[1] Orfanidis, Sophocles J. Introduction to Signal Processing. Upper Saddle River, NJ: PrenticeHall, 1996.