Second-order tunable notching and peaking IIR filter
NotchPeakFilter object filters each channel
of the input using IIR filter implementation.
To filter each channel of the input:
Starting in R2016b, instead of using the
to perform the operation defined by the System
object™, you can
call the object with arguments, as if it were a function. For example,
= step(obj,x) and
y = obj(x) perform
npFilter = dsp.NotchPeakFilter returns
a second-order 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
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 name-value
pair arguments in any order as
npFilter = dsp.NotchPeakFilter('specification','Quality
factor and center frequency') specifies the quality factor
(Q factor) of the notch or peak filter instead of the
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
be a scalar between
-1 corresponding to
1 corresponding to the Nyquist frequency. The
be a scalar between
-1 corresponding to the largest
1 corresponding to the smallest
bandwidth. Both coefficient values are tunable.
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
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|
|Common to All System Objects|
Allow System object property value changes
This example shows how to use dsp.NotchPeakFilter as a notch filter with center frequency of 5000 Hz and a 3 dB bandwidth of 500 Hz.
Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent
step syntax. For example, myObject(x) becomes step(myObject,x).
npFilter = dsp.NotchPeakFilter('CenterFrequency',5000,'Bandwidth',500); sa = dsp.SpectrumAnalyzer('SampleRate',44100,... 'PlotAsTwoSidedSpectrum',false,'SpectralAverages',50); for i=1:5000 y = npFilter(randn(1024,1)); sa(y); if (i==2500) % Tune center frequency to 10000 npFilter.CenterFrequency = 10000; end end release(npFilter) release(sa)
The design equations for this filter are:
The previous equation is for peak filter, and the following equation is for notch filter.
The filter is implemented as follows:
Notice that Gcf depends only on the center frequency, and G3dB depends only on the 3 dB bandwidth.
 Orfanidis, Sophocles J. Introduction to Signal Processing. Upper Saddle River, NJ: Prentice-Hall, 1996.