Main Content

Second-order 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:

Create the

`dsp.NotchPeakFilter`

object and set its properties.Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?.

returns a
second-order notching and peaking IIR filter that independently filters each channel of
the input over time, using a specified center frequency and 3 dB bandwidth.`npFilter`

= dsp.NotchPeakFilter

```
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.

`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.

`npFilter = dsp.NotchPeakFilter(`

returns a notch filter with each specified property name set to the specified value.
Unspecified properties have default values.`Name,Value`

)

To use an object function, specify the
System object™ as the first input argument. For
example, to release system resources of a System object named `obj`

, use
this syntax:

release(obj)

The design equation for the peak filter is:

$$H(z)=(1-b)\frac{1-{z}^{-2}}{1-2b\mathrm{cos}{w}_{0}{z}^{-1}+(2b-1){z}^{-2}}$$

The design equation for the notch filter is:

$$H(z)=b\frac{1-2\mathrm{cos}{w}_{0}{z}^{-1}+{z}^{-2}}{1-2b\mathrm{cos}{w}_{0}{z}^{-1}+(2b-1){z}^{-2}}$$

with

$$b=\frac{1}{1+\mathrm{tan}(\Delta w/2)}$$

where *ω*_{0} =
2π*f*_{0}/*f*_{s}
is the center frequency in radians/sample (*f*_{0} is
the center frequency in Hz and *f*_{s} is the sampling
frequency in Hz). Δ*ω* =
2πΔ*f*/*f*_{s} is the 3 dB
bandwidth in radians/sample (Δ*f* is the 3 dB bandwidth in Hz). Note that
the two filters are complementary:

$$\begin{array}{l}{H}_{\text{notch}}(z)+{H}_{\text{peak}}(z)=1\\ \text{theycanbewrittenas:}\\ {H}_{\text{peak}}(z)=\frac{1}{2}\left[1-A(z)\right]\\ {H}_{\text{notch}}(z)=\frac{1}{2}\left[1+A(z)\right]\\ \text{where}A\text{(z)isa}{2}^{\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}=2b-1\end{array}$$

The filter is implemented as follows:

where

$$\begin{array}{l}{G}_{\text{3dB}}={a}_{2}=2b-1\\ {G}_{\text{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: Prentice-Hall,
1996.