EngeeDSP.NotchPeakFilter
Configurable notch and narrow-band second-order IIR filter.
| Library |
|
| Block |
Description
To implement a second-order notch or narrow-band IIR filter, follow these steps:
-
Create an object EngeeDSP.NotchPeakFilter and set its properties.
-
Call the object with arguments as if it were a function.
To learn more about how to work with system objects, see Engee System Objects.
Syntax
Creation
-
npFilter = EngeeDSP.NotchPeakFilter()returns a second-order notch and narrow-band IIR filter, which independently filters each channel of the input signal in time using a given center frequency and bandwidth.3dB. -
npFilter = EngeeDSP.NotchPeakFilter(Specification="Quality factor and center frequency")the quality factor (Q-factor) of the notch or narrowband filter is indicated instead of the bandwidth3dB. -
npFilter = EngeeDSP.NotchPeakFilter(Specification="Coefficients")The values of the coefficients that directly affect the bandwidth and center frequency are indicated, rather than the design parameters in Hz. This eliminates the need for trigonometric calculations when setting up the characteristics. -
npFilter = EngeeDSP.NotchPeakFilter(Name=Value)returns a notch or narrow-band IIR filter with the specified propertyName, set to the specified valueValue. You can specify additional arguments as a name-value pair in any order (Name1=Value1,…,NameN=ValueN). Unspecified properties have default values.Example:
npFilter = EngeeDSP.NotchPeakFilter(CenterFrequency=5000,Bandwidth=500)
Using
-
Yn = npFilter(x)filters each channel (column) of the input signalx, creating the output signal of the notch filterYn. -
Yn, Yp = npFilter(x)filters each channel (column) of the input signalx, creating the output signal of the notch filterYnand the output signal of the narrowband filterYp.
Arguments
Input arguments
x — input signal
+
vector | the matrix
Details
The input signal is specified as a vector or matrix.
| Типы данных |
|
| Support for complex numbers |
Yes |
Output arguments
Yn is the output signal of the notch filter
+
vector | the matrix
Details
The output signal of the notch filter, returned as a vector or matrix.
| Типы данных |
|
| Support for complex numbers |
Yes |
Yp is the output signal of the narrowband filter
+
vector | the matrix
Details
The output signal of a narrowband filter, returned as a vector or matrix.
| Типы данных |
|
| Support for complex numbers |
Yes |
Features
# Specification — filter characteristics
+
"Bandwidth and center frequency" (by default) | "Quality factor and center frequency" | "Coefficients"
Details
Specify the properties that the block uses to design the filter.:
-
"Bandwidth and center frequency"— designing a filter using properties Bandwidth and CenterFrequency or NormalizedBandwidth and*NormalizedCenterFrequency*. -
"Coefficient"— designing a filter using properties BandwidthCoefficient and CenterFrequencyCoefficient. -
"Quality factor and center frequency"— designing a filter using the properties QualityFactor and CenterFrequency or NormalizedCenterFrequency.
#
Bandwidth —
bandwidth 3 dB, in Hz
+
2205 (default) | positive scalar
Details
Bandwidth 3 The dB of the filter, set as a positive scalar in Hz.
Dependencies
To use this property, set the Specification value "Bandwidth and center frequency", and for the property NormalizedFrequency the value false.
#
NormalizedBandwidth —
bandwidth 3 dB, in normalized units
+
0.1 (by default) | a positive scalar is less than 1.0
Details
Bandwidth 3 The dB of the filter, set as a positive scalar, is less than 1.0 in normalized units.
If, when creating an object, the NormalizedFrequency property is set to true if no bandwidth is set, then the object will automatically set the default bandwidth in normalized frequency units using the default sampling rate. 44100 Hz.
npFilter = EngeeDSP.NotchPeakFilter(NormalizedFrequency = true)
NotchPeakFilter:
Specification=Bandwidth and center frequency
NormalizedBandwidth=0.1
NormalizedCenterFrequency=0.5
SampleRate=44100
NormalizedFrequency=true
FilterOutput=NotchAndPeak
If the property NormalizedFrequency is set to true After creating the object, you must specify the bandwidth in normalized units before running the object algorithm.
npFilter = EngeeDSP.NotchPeakFilter()
NotchPeakFilter:
Specification=Bandwidth and center frequency
Bandwidth=2205
CenterFrequency=11025
SampleRate=44100
NormalizedFrequency=false
FilterOutput=NotchAndPeak
To specify a normalized frequency value, set the NormalizedFrequency property to true and manually convert the frequency value in Hz to a normalized value using half the sampling frequency of the input signal in Hz. For example, if the input sampling rate is compose 44100 Hz, then the corresponding bandwidth value in normalized units is .
npFilter.NormalizedFrequency = true
npFilter.NormalizedBandwidth = 2205/(44100/2)
npFilter
NotchPeakFilter:
Specification=Bandwidth and center frequency
NormalizedBandwidth=0.1
NormalizedCenterFrequency=0.5
SampleRate=44100
NormalizedFrequency=true
FilterOutput=NotchAndPeak
Dependencies
To use this property, set the Specification value "Bandwidth and center frequency", and for the property NormalizedFrequency the value true.
# CenterFrequency — the center frequency of a notch or narrowband filter, in Hz
+
11025 (by default) | positive scalar
Details
The center frequency of the filter, set as a positive scalar in Hz.
Dependencies
To use this property, set the Specification value "Bandwidth and center frequency", and for the property NormalizedFrequency the value false.
# NormalizedCenterFrequency — the center frequency of a notch or narrowband filter, in normalized units
+
0.5 (by default) | a positive scalar is less than 1.0
Details
The center frequency of a notch or narrowband filter, set as a positive scalar, is less than 1.0 in normalized units.
If, when creating an object, the NormalizedFrequency property is set to true if the center frequency is not set, then the object will automatically set the default center frequency in normalized frequency units using the default sampling rate. 44100 Hz.
npFilter = EngeeDSP.NotchPeakFilter(NormalizedFrequency = true)
NotchPeakFilter:
Specification=Bandwidth and center frequency
NormalizedBandwidth=0.1
NormalizedCenterFrequency=0.5
SampleRate=44100
NormalizedFrequency=true
FilterOutput=NotchAndPeak
If the property NormalizedFrequency is set to true After creating the object, it is necessary to specify the center frequency in normalized units before running the object algorithm.
npFilter = EngeeDSP.NotchPeakFilter()
NotchPeakFilter:
Specification=Bandwidth and center frequency
Bandwidth=2205
CenterFrequency=11025
SampleRate=44100
NormalizedFrequency=false
FilterOutput=NotchAndPeak
To specify a normalized frequency value, set the NormalizedFrequency property to true and manually convert the frequency value in Hz to a normalized value using half the sampling frequency of the input signal in Hz. For example, if the input sampling rate is compose 44100 Hz, then the corresponding value of the central frequency in normalized units is .
npFilter.NormalizedFrequency = true
npFilter.NormalizedCenterFrequency = 11025/(44100/2)
npFilter
NotchPeakFilter:
Specification=Bandwidth and center frequency
NormalizedBandwidth=0.1
NormalizedCenterFrequency=0.5
SampleRate=44100
NormalizedFrequency=true
FilterOutput=NotchAndPeak
Dependencies
To use this property, set the Specification value "Bandwidth and center frequency" or "Quality factor and center frequency", and for the property NormalizedFrequency the value true.
# QualityFactor — the quality of a notch or narrowband filter
+
5 (by default) | positive scalar
Details
The Q-factor of a notch or narrowband filter, specified as a real positive scalar. Q factor is defined as the ratio of the center frequency to the bandwidth. The higher the Q factor, the narrower the suppression or transmission band.
Dependencies
To use this property, set the Specification value "Quality factor and center frequency".
# SampleRate is the sampling frequency of the input signal, in Hz
+
44100 (by default) | positive scalar
Details
The sampling frequency of the input signal, set as a scalar in Hz.
Dependencies
To use this property, set the Specification value "Bandwidth and center frequency" or "Quality factor and center frequency", and for the property NormalizedFrequency the value false.
# BandwidthCoefficient — bandwidth factor
+
0.726554 (by default) | a real scalar in the range [-1, 1]
Details
The coefficient determining the bandwidth 3 dB, set as a scalar in the range from −1 before 1:
-
−1corresponds to the maximum bandwidth3dB (one-fourth of the sampling rate of the input signal); -
1corresponds to the minimum bandwidth (0Hz, i.e. frequency-independent filter).
Dependencies
To use this property, set the Specification value "Coefficients".
# CenterFrequencyCoefficient — bandwidth factor
+
0.0 (by default) | a real scalar in the range [-1, 1]
Details
The coefficient that determines the center frequency of the filter, set as a scalar in the range from −1 before 1:
-
−1corresponds to the minimum central frequency (0Hz); -
1corresponds to the maximum center frequency (half of the sampling frequency of the input signal).
Dependencies
To use this property, set the Specification value "Coefficients".
# NormalizedFrequency — option to set frequencies in normalized units
+
false (by default) | true
Details
Option to set frequencies in normalized units:
-
false— the values of the bandwidth and center frequency are specified in Hz and must be less than half the value SampleRate; -
true— The bandwidth and center frequency values are specified in normalized frequency units. The values must be positive scalars less than1.0.
Dependencies
To use this property, set the Specification value "Bandwidth and center frequency" or "Quality factor and center frequency".
# FilterOutput — select a filter for data output
+
"NotchAndPeak" (by default) | "Notch" | "Peak"
Details
Selecting the output data:
-
"NotchAndPeak"— the output signal after passing the notch and narrowband filter; -
"Notch"— output signal after passing through the notch filter; -
"Peak"— the output signal after passing the narrowband filter.
Algorithms
The equation for a narrowband filter design is as follows:
The equation for the notch filter design is as follows:
In these equations
where
-
— the central frequency in Hz;
-
— sampling rate in Hz;
-
— bandwidth
3dB in Hz.
Please note that these two filters complement each other.:
They can be rewritten as
where — frequency-independent second-order filter:
The filter is implemented as follows:
In the picture:
Please note that depends only on the central frequency, and — only from bandwidth 3 dB.