Documentation Center

  • Trial Software
  • Product Updates

Contents

dsp.NotchPeakFilter System object

Package: dsp

Second-order tunable notching and peaking IIR filter

Description

The NotchPeakFilter object filters each channel of the input using IIR filter implementation.

To filter each channel of the input:

  1. Define and set up your NotchPeak filter. See Construction.

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

Construction

H = 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 0 and half the sample rate.

H = dsp.NotchPeakFilter('PropertyName',PropertyValue, ...) 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 (Name1,Value1,...,NameN,ValueN).

H = 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.

H = 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.

Properties

Specification

Filter specification

Set the specification as one of 'Bandwidth and center frequency' | 'Quality factor and center frequency' | 'Coefficients'. The default is 'Bandwidth and center frequency'.

Bandwidth

3 dB bandwidth

Specify the filter's 3 dB bandwidth as a finite positive numeric scalar in Hertz. This property is applicable only if specification is 'Bandwidth and center frequency'. The default is 2205 Hz. This property is tunable.

CenterFrequency

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 specification is 'Bandwidth and center frequency' | 'Quality factor and center frequency'. The default is 11025 Hz. This property is tunable.

QualityFactor

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 specification is set to 'Quality factor and center frequency'. The default value is 5. This property is tunable.

SampleRate

Sample rate of input

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

BandwidthCoefficient

Bandwidth coefficient

Specify the value that determines the filter's 3 dB bandwidth as a finite numeric scalar between 0 and 1. Where 0 corresponds to the maximum 3 dB bandwidth (SampleRate/4), and 1 corresponds to the minimum 3 dB bandwidth (0 Hz, an allpass filter). The default is 0.72654. This property is only applicable if specification is set to 'Coefficients'. This property is tunable.

CenterFrequencyCoefficient

Center frequency coefficient

Specify the coefficient that determines the filter's center frequency as a finite numeric scalar between -1 and 1. Where -1 corresponds to the minimum center frequency (0 Hz), and 1 corresponds to the maximum center frequency (SampleRate/2 Hz). This property is only applicable if specification is set to 'Coefficients'. The default is 0 which corresponds to SampleRate/4 Hz. This property is tunable.

Methods

cloneCreate System object with same property values
getBandwidthGet 3 dB bandwidth
getCenterFrequencyGet center frequency
getOctaveBandwidthBandwidth in number of octaves
getQualityFactorGet quality factor
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset the internal states of notch or peak filter
stepProcess input using the notch or peak filter algorithm
tfTransfer function

Examples

expand all

Notch filter

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.

    h = dsp.NotchPeakFilter('CenterFrequency',5000,'Bandwidth',500);
    hscope =  dsp.SpectrumAnalyzer('SampleRate',44100,...
        'PlotAsTwoSidedSpectrum',false,'SpectralAverages',50);
    for i=1:5000
        y = step(h,randn(1024,1));
        step(hscope,y);
        if (i==2500)
            % Tune center frequency to 10000
            h.CenterFrequency = 10000;
        end
    end
    release(h)
    release(hscope)

Algorithms

The design equations for this filter are:

The previous equation is for peak filter, and the following equation is for notch filter.

With

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

The filter is implemented as follows:

where

Notice that Gcf depends only on the center frequency, and G3dB depends only on the 3 dB bandwidth.

References

[1] Sophocles J. Orfanidis, Introduction to Signal Processing, Prentice-Hall, Upper Saddle River, New Jersey

See Also

| |

Was this topic helpful?