dfilt
Discrete-time filter
Syntax
Hd = dfilt.
structure
(input1,...)
Description
Hd = dfilt.
returns a discrete-time filter, structure
(input1,...)Hd
, of type
structure
. Each structure takes one or more inputs. If you
specify a dfilt
.structure
with no inputs, a
default filter is created.
Note
You must use a structure
with dfilt
.
Hd =
[dfilt.
returns a vector containing structure
(input1,...),dfilt.structure
(input1,...),...]dfilt
filters.
Structures
Available structures for the dfilt
object are shown below. The
target block for the block
method depends on the filter structure.
Depending on the target block, the DSP System Toolbox™ software may be required.
dfilt.structure | Description | Coefficient Mapping Support in realizemdl | Target Filter Block for |
---|---|---|---|
| Delay | Not supported | Delay Requires DSP System Toolbox |
| Direct-form I | Supported | Discrete Filter |
| Direct-form I, second-order sections | Supported | Discrete Filter Requires DSP System Toolbox |
| Direct-form I transposed | Supported | Discrete Filter |
| Direct-form I transposed, second-order sections | Supported | Biquad Filter Requires DSP System Toolbox |
| Direct-form II | Supported | Discrete Filter |
| Direct-form II, second-order sections | Supported | Discrete Filter |
| Direct-form II transposed | Supported | Discrete Filter |
| Direct-form II transposed, second-order sections | Supported | Biquad Filter Requires DSP System Toolbox |
| Direct-form FIR | Supported | Discrete FIR Filter |
| Direct-form FIR transposed | Supported | Discrete FIR Filter |
| Direct-form symmetric FIR | Supported | Discrete FIR Filter |
| Direct-form antisymmetric FIR | Supported | Discrete FIR Filter |
| Overlap-add FIR | Not supported | Overlap-Add FFT Filter Requires DSP System Toolbox |
| Lattice allpass | Supported | Not supported |
| Lattice autoregressive (AR) | Supported | Allpole Filter Requires DSP System Toolbox |
| Lattice autoregressive moving- average (ARMA) | Supported | Not supported |
| Lattice moving-average (MA) for maximum phase | Supported | Not supported |
| Lattice moving-average (MA) for minimum phase | Supported | Discrete FIR Filter |
| State-space | Supported. | Not supported |
| Scalar gain object | Supported | Gain Requires DSP System Toolbox |
| Filters arranged in series | Supported | Target blocks depend on filter structures in the series |
| Filters arranged in parallel | Supported | Target blocks depend on filter structures in the parallel system |
For more information on each structure, use the syntax help
dfilt.
structure
at the MATLAB® prompt or refer to its reference page.
Methods
Methods provide ways of performing functions directly on your dfilt
object without having to specify the filter parameters again. You can apply these methods
directly on the variable you assigned to your dfilt
object.
For example, if you create a dfilt
object, Hd
, you
can check whether it has linear phase with islinphase(Hd)
or obtain its
frequency response values with h=freqz(Hd)
. You can use all of the
methods below in this way.
Note
If your variable is a 1-D array of dfilt
filters, the method is
applied to each object in the array. Only freqz
,
grpdelay
, impz
, is
*,
order
, and stepz
methods can be applied to arrays.
The zplane
method can be applied to an array only if it is used without
outputs.
Some of the methods listed below have the same name as Signal Processing Toolbox™ functions and they behave similarly. This is called overloading of functions.
Available methods are:
Method | Description |
---|---|
| Adds a stage to a |
|
The
|
| Returns the series combination of two |
| Returns the filter coefficients in a structure containing fields that use
the same property names as those in the original
|
| Converts a |
| Writes a filter coefficient ASCII file. The file can contain a single
filter or a vector of objects. Default file name is
|
| Returns the frequency-domain coefficients used when filtering with a
|
Performs filtering using the
| |
| Returns the type (1-4) of a linear phase FIR filter. |
Plots the frequency response. Note that unlike the
| |
Plots the group delay. | |
Plots the impulse response. | |
| Returns the length of the impulse response. |
| Displays brief |
| Returns a logical |
| Returns a logical |
| Returns a logical |
| Returns a logical |
| Returns a logical |
| Returns a logical |
| Returns a logical |
| Returns a logical |
| Returns a logical |
| Returns a logical |
| Returns a logical |
| Returns the number of sections in a second-order sections filter. If a
multistage filter contains stages with multiple sections, using
|
| Returns the number of stages of the filter, where a stage is a separate, modular filter. |
| Returns the number of states for an object. |
| Returns the filter order. If |
| Returns the parallel combination of two |
| Plots the phase response. |
| (Available only with Simulink software.)
The following properties are available:
The following
properties optimize the block structure. Specifying
|
| Removes a stage from a cascade or parallel |
| Overwrites a stage of a cascade or parallel |
| Converts the
|
| Converts the |
| Plots the step response.
|
| Converts the |
| Converts the |
| Plots the zero-phase response. |
| Converts the |
Plots a pole-zero plot. |
For more information on each method, use the syntax help
dfilt/
method
at the MATLAB prompt.
Viewing Properties
As with any object, you can use get
to view a
dfilt
properties. To see a specific property, use
get(Hd,'property')
To see all properties for an object, use
get(Hd)
Changing Properties
To set specific properties, use
set(Hd,'property1',value,'property2',value,...)
Note that you must use single quotation marks around the property name.
Alternatively, you can get or set a property value with
Object.property
:
b = [0.05 0.9 0.05]; Hd = dfilt.dffir(b); % Lowpass direct-form I FIR filter Hd.arithmetic % get arithmetic property % returns double Hd.arithmetic = 'single'; % Set arithmetic property to single precision
Copying an Object
To create a copy of an object, use the copy
method.
H2 = copy(Hd)
Note
Using the syntax H2 = Hd
copies only the object handle
and does not create a new object.
Converting Between Filter Structures
To change the filter structure of a dfilt
object
Hd
, use
Hd2=convert(Hd,'structure_name');
where structure_name
is any valid structure name in single quotes. If
Hd
is a cascade
or parallel
structure, each of its stages is converted to the new structure.
Using Filter States
Two properties control the filter states:
states
— stores the current states of the filter. Before the filter is applied, the states correspond to the initial conditions and after the filter is applied, the states correspond to the final conditions. Fordf1
,df1t
,df1sos
anddf1tsos
structures,states
returns afiltstate
object.PersistentMemory
— controls whether filterstates
are saved. The default value is'false'
, which causes the initial conditions to be reset to zero before filtering and turns off the display ofstates
information. SettingPersistentMemory
to'true'
allows the filter to use your initial conditions or to reuse the final conditions of a previous filtering operation as the initial conditions of the next filtering operation. It also displays information about the filterstates
.Note
If you set
states
and want to use them for filtering, you must setPersistentMemory
to'true'
before you use the filter.
Examples
Create a direct-form I filter and use a method to see if it is stable.
[b,a] = butter(8,0.25); Hd = dfilt.df1(b,a)
If a dfilt
's numerator values do not fit on a single line, a
description of the vector is displayed. To see the specific numerator values for this example,
use
get(Hd,'numerator')
or alternatively
Hd.numerator
Refer to the reference pages for each structure for more examples.
Version History
Introduced before R2006a