Documentation |
Package: dsp
Static or time-varying digital filter
Note: Use of dsp.DigitalFilter object in future releases is not recommended. Existing instances will continue to operate, but certain functionality will be disabled. See Functionality being removed or replaced for blocks and System objects. We strongly recommend using dsp.FIRFilter, dsp.IIRFilter, dsp.BiquadFilter, or dsp.AllpoleFilter System objects. |
The DigitalFilter object filters each channel of the input using static or time-varying digital filter implementations.
To filter each channel of the input using digital filter implementation:
Define and set up your IIR digital filter. See Construction.
Call step to filter each channel according to the properties of dsp.DigitalFilter. The behavior of step is specific to each object in the toolbox.
H = dsp.DigitalFilter returns a default IIR digital filter object, H, which independently filters each channel of the input over successive calls to the step method, using a specified digital filter implementation. The default numerator coefficients are [1 2] and denominator coefficients are [1 0.1].
H = dsp.DigitalFilter('PropertyName',PropertyValue, ...) returns a digital filter object, H, with each property set to the specified value.
TransferFunction |
Type of filter transfer function Specify the type of digital filter transfer function as one of | IIR (poles & zeros) | IIR (all poles) | FIR (all zeros) |. The default is IIR (poles & zeros). | |||
Structure |
Filter structure Specify the filter structure.
| |||
CoefficientsSource |
Source of filter coefficients Specify the source of the filter coefficients as one of | Property | Input port |. The default is Property. When you specify Input port, the digital filter object updates the time-varying filter once every frame, when the FrameBasedProcessing property is true. When the FrameBasedProcessing property is false, it updates once every sample. | |||
Numerator |
Numerator coefficients Specify the filter numerator coefficients as a real or complex numeric vector. This property applies when you set the TransferFunction property to FIR (all zeros), the CoefficientsSource property to Property, and the Structure property is not set to Lattice MA. This property also applies when you set the TransferFunction property to IIR (poles & zeros), the CoefficientsSource to Property, and the TransferFunction property to Direct form, Direct form symmetric, Direct form antisymmetric, or Direct form transposed. The default is [1 2]. This property is tunable. | |||
Denominator |
Denominator coefficients Specify the filter denominator coefficients as a real or complex numeric vector. This property applies when you set the TransferFunction property to IIR (all poles), the CoefficientsSource property to Property and the Structure property is not set to Lattice AR. This property also applies when you set the TransferFunction property to IIR (poles & zeros), the CoefficientsSource to Property, and the TransferFunction property to Direct form, Direct form symmetric, Direct form antisymmetric, or Direct form transposed. When the TransferFunction property is IIR (poles & zeros), the numerator and denominator must have the same complexity. The default is [1 0.1]. This property is tunable. | |||
ReflectionCoefficients |
Reflection coefficients of lattice filter structure Specify the reflection coefficients of a lattice filter as a real or complex numeric vector. This property applies when you set the TransferFunction property to FIR (all zeros), the Structure property to Lattice MA, and the CoefficientsSource property to Property. This property also applies when you set the TransferFunction property to IIR (all poles), the Structure property to Lattice AR, and the CoefficientsSource property to Property. The default is [0.2 0.4]. This property is tunable. | |||
SOSMatrix |
SOS matrix of biquad filter structure Specify the second-order section (SOS) matrix of a biquad filter as an M-by-6 matrix, where M is the number of sections in the filter. Each row of the SOS matrix contains the numerator and denominator coefficients of the corresponding filter section. The first three elements of each row are the numerator coefficients and the last three elements are the denominator coefficients. You can use real or complex coefficients. This property applies when you set the TransferFunction property to IIR (poles and zeros), the CoefficientsSource property to Property, and the Structure property to Biquad direct form I (SOS), Biquad direct form I transposed (SOS), Biquad direct form II (SOS), or Biquad direct form II transposed (SOS). The default is [1 0.3 0.4 1 0.1 0.2]. This property is tunable. | |||
ScaleValues |
Scale values of biquad filter structure Specify the scale values to apply before and after each section of a biquad filter. ScaleValues must be a scalar or a vector of length M+1, whereM is the number of sections. If you specify a scalar value, that value is used as the gain value before the first section of the second-order filter and the rest of the gain values are set to 1. If you specify a vector of M+1 values, each value is used for a separate section of the filter. This property applies when you set the TransferFunction property to IIR (poles & zeros), the CoefficientsSource property to Property, and the Structure property to Biquad direct form I (SOS), Biquad direct form I transposed (SOS), Biquad direct form II (SOS), or Biquad direct form II transposed (SOS). The default is 1. This property is tunable. | |||
IgnoreFirstDenominatorCoefficient |
Assume first denominator coefficient is 1 Setting this Boolean property to true reduces the number of computations to produce the digital filter output by omitting the first denominator term, a0, (poles side) in the filter structure. The object output is invalid when you set this property to true when the first denominator coefficient is not always 1 for your time-varying filter. The object ignores this property for fixed-point inputs, because this object does not support nonunity a0 coefficients for fixed-point inputs. This property applies when you set the CoefficientsSource property to Input port, the TransferFunction property to IIR (all poles), and the Structure property is not set to Lattice AR. This property also applies when you set the CoefficientsSource property to Input port, the TransferFunction property to IIR (poles & zeros), and the Structure property to Direct form, Direct form symmetric, Direct form antisymmetric, or Direct form transposed. The default is true. | |||
InitialConditions |
Initial conditions for all poles or all zeros filter Specify the initial conditions of the filter states. When the TransferFunction property is FIR (all zeros) or IIR (all poles), the number of states or delay elements equals the number of reflection coefficients for the lattice structure, or the number of filter coefficients–1 for the other direct form structures. When the TransferFunction property is IIR (poles & zeros), the number of states for direct form II and direct form II transposed structures equals the max(N,M)–1, where N and M are the number of poles and zeros, respectively. You can specify the initial conditions as a scalar, vector, or matrix. If you specify a scalar value, the digital filter object initializes all delay elements in the filter to that value. If you specify a vector whose length equals the number of delay elements in the filter, each vector element specifies a unique initial condition for the corresponding delay element. The object applies the same vector of initial conditions to each channel of the input signal. If you specify a vector whose length equals the product of the number of input channels and the number of delay elements in the filter, each element specifies a unique initial condition for the corresponding delay element in the corresponding channel. If you specify a matrix with the same number of rows as the number of delay elements in the filter, and one column for each channel of the input signal, each element specifies a unique initial condition for the corresponding delay element in the corresponding channel. This property applies when you do not set the Structure property to Direct Form I, Direct Form I transposed, Biquad direct form I (SOS), or Biquad direct form I transposed (SOS). The default is 0. | |||
NumeratorInitialConditions |
Initial conditions on zeros side Specify the initial conditions of the filter states on the side of the filter structure with the zeros. This property applies when you set the TransferFunction property to IIR (poles & zeros) and the Structure property is Direct form I, Direct form I transposed, Biquad direct form I (SOS), or Biquad direct form I transposed (SOS). The default is 0. See the InitialConditions property for information on setting initial conditions. | |||
DenominatorInitialConditions |
Initial conditions on poles side Specify the initial conditions of the filter states on the side of the direct form I (noncanonic) filter structure with the poles. This property applies when you set the TransferFunction property to IIR (poles & zeros) and the Structure property to Direct form I, Direct form I transposed, Biquad direct form I (SOS), or Biquad direct form I transposed (SOS). The default is 0. See the InitialConditions property for information on setting initial conditions. | |||
FrameBasedProcessing |
Enable frame-based processing Set this property to true to enable frame-based processing. Set this property to false to enable sample-based processing. The default is true. |
clone | Create static or time-varying digital filter with same property values |
getNumInputs | Number of expected inputs to step method |
getNumOutputs | Number of outputs of step method |
isLocked | Locked status for input attributes and nontunable properties |
release | Allow property value and input characteristics changes |
reset | Reset internal states of digital filter |
step | Filter input with digital filter object |
Use an FIR filter to apply a low pass filter to a waveform with two sinusoidal components:
t = [0:63]./32e3; xin = (sin(2*pi*4e3*t)+sin(2*pi*12e3*t)) / 2; hSR = dsp.SignalSource(xin', 4); hLog = dsp.SignalSink; hFilt = dsp.DigitalFilter; hFilt.TransferFunction = 'FIR (all zeros)'; hFilt.Numerator = fir1(10,0.5); while ~isDone(hSR) input = step(hSR); filteredOutput = step(hFilt,input); step(hLog,filteredOutput); end filteredResult = hLog.Buffer; periodogram(filteredResult,[],[],32e3)
This object implements the algorithm, inputs, and outputs described on the Digital Filter block reference page. The object properties correspond to the block parameters.
Both this object and its corresponding block let you specify whether to process inputs as individual samples or as frames of data. The object uses the FrameBasedProcessing property. The block uses the Input processing parameter. See Set the FrameBasedProcessing Property of a System object for more information.
dsp.AllpoleFilter | dsp.BiquadFilter | dsp.FIRFilter | dsp.IIRFilter