dfilt
Discrete-time filter
Syntax
hd = dfilt.
structure
(input1,...)
hd = design(d,'designmethod')
Description
hd = dfilt.
returns a discrete-time filter, structure
(input1,...)hd
, of type
structure
. Each structure takes one or more inputs. When you specify
a dfilt
.structure
with no inputs, a default filter
is created.
You must use a structure
with dfilt
.
You can get a vector of dfilt
filters by concatenating
dfilt.
as an array.structure
(input1,...)
hd = [dfilt.dffir, dfilt.df1, dfilt.df2]
hd = dfilt.dffir dfilt.df1 dfilt.df2
Structures
Structures for dfilt.structure
specify the
type of filter structure. Available types of structures for dfilt
are
shown below.
dfilt.structure | Description | Coefficient Mapping Support in realizemdl |
---|---|---|
| Allpass filter | Supported |
| Cascade of allpass filter sections | Supported |
| Cascade of allpass wave digital filters | Supported |
| Delay | Not supported |
| Direct-form I | Supported |
| Direct-form I, second-order sections | Supported |
| Direct-form I transposed | Supported |
| Direct-form I transposed, second-order sections | Supported |
| Direct-form II | Supported |
| Direct-form II, second-order sections | Supported |
| Direct-form II transposed | Supported |
| Direct-form II transposed, second-order sections | Supported |
| Direct-form FIR | Supported |
| Direct-form FIR transposed | Supported |
| Direct-form symmetric FIR | Supported |
| Direct-form antisymmetric FIR | Supported |
| Generic fractional delay Farrow filter | Supported |
| Linear fractional delay Farrow filter | Not supported |
| Overlap-add FIR | Not supported |
| Lattice allpass | Supported |
| Lattice autoregressive (AR) | Supported |
| Lattice autoregressive moving- average (ARMA) | Supported |
| Lattice moving-average (MA) for maximum phase | Supported |
| Lattice moving-average (MA) for minimum phase | Supported |
| Coupled, allpass lattice | Supported |
| Coupled, allpass lattice with power complementary output | Supported |
| State-space | Supported |
| Scalar gain object | Supported |
| Allpass wave digital filter object | Supported |
| Filters arranged in series | Supported |
| Filters arranged in parallel | Supported |
For more information on each structure, refer to its reference page.
hd = design(d,'designmethod')
returns
the dfilt
object hd
resulting
from the filter specification object d
and the
design method you specify in designmethod
.
When you omit the designmethod
argument, design
uses the default design method to
construct a filter from the object d
.
With this syntax, you design filters by:
Specifying the filter specifications, such as the response shape (perhaps highpass) and details (passband edges and attenuation).
Selecting a method (such as
equiripple
) to design the filter.Applying the method to the specifications object with
design(d,'designmethod)
.
Using the specification-based technique can be more effective than the coefficient-based filter design techniques.
Design Methods for Design Syntax
When you use the hd = design(d,'
syntax,
you have a range of design methods available depending on designmethod
')d
,
the filter specification object. The next table lists all of the design
methods in the toolbox.
Design Method | Filter Design Result |
---|---|
Butterworth IIR | |
Chebyshev Type I IIR | |
Chebyshev Type II IIR | |
Elliptic IIR | |
Equiripple with the same ripple in the pass and stopbands | |
Least-squares FIR | |
Frequency-Sampled FIR | |
Interpolated FIR | |
Least Pth norm IIR | |
Least-Squares IIR | |
Kaiser-windowed FIR | |
Fractional delay filter | |
Multistage FIR | |
Windowed FIR |
As the specifications object d
changes, the
available methods for designing filters from d
also
change. For instance, if d
is a lowpass filter
with the default specification 'Fp,Fst,Ap,Ast'
,
the applicable methods are:
% Create an object to design a lowpass filter. d=fdesign.lowpass; designmethods(d) % What design methods apply to object d?
If you change the specification to 'N,F3dB'
, the available design methods
change:
d=fdesign.lowpass('N,F3dB'); designmethods(d)
Analysis 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)
,
view its frequency response plot with fvtool(hd)
,
or obtain its frequency response values with h
= freqz(hd)
. You can use all of the
methods described here in this way.
Note
If your variable hd
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 zplane
is used
without outputs.
Some of the methods listed here have the same name as functions in Signal Processing Toolbox™ software. They behave similarly.
Method | Description |
---|---|
| Adds a stage to a |
|
|
| 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. The 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 in FVTool. Unlike the | |
Plots the group delay in FVTool. | |
Plots the impulse response in FVTool. | |
| Returns the length of the impulse response. |
| Displays |
| 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 in FVTool. |
| (Available only with Simulink.)
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 in FVTool.
|
| Converts the |
Converts the | |
Plots the zero-phase response in FVTool. | |
Converts the | |
Plots a pole-zero plot in FVTool. |
Viewing Properties
As with any object, 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)
Note
dfilt
objects include an arithmetic
property.
You can change the internal arithmetic of the filter from double-
precision to single-precision using: hd.arithmetic
= 'single'
.
If you have Fixed-Point Designer™ software, you can change
the arithmetic
property to fixed-point using: hd.arithmetic = 'fixed'
Changing Properties
To set specific properties, use
set(hd,'property1',value,'property2',value,...)
You must use single quotation marks around the property name. Use single quotation marks
around the value
argument when the value is a character vector, such as
specifyall
or fixed
.
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, independent object.
Converting Between Filter Structures
To change the filter structure of a dfilt
object hd
,
use
hd2 = convert(hd,'structure_charactervector');
where structure_charactervector
is any valid structure name in single
quotation marks. If hd
is a cascade
or
parallel
structure, each stage 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 afiltstates
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 from a previous filtering operation as the initial conditions of the next filtering operation. Thetrue
setting also displays information about the filterstates
.
Note
If you set the states
and want to use them
for filtering, you must set PersistentMemory
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); isstable(hd)
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
B = get(hd,'numerator'); % or B1 = hd.numerator;
Create an array containing two dfilt
objects,
apply a method and verify that the method acts on both objects. Use
a method to test whether the objects are FIR objects.
b = fir1(5,.5); hd = dfilt.dffir(b); % Create an FIR filter object [b,a] = butter(5,.5); % Create IIR filter hd(2) = dfilt.df2t(b,a); % Create DF2T object and place % in the second column of hd. [h,w] = freqz(hd); test_fir = isfir(hd) % hd(1) is FIR and hd(2) is not.
Refer to the reference pages for each structure for more examples.
Version History
Introduced in R2011a