Discretetime, directform I filter
hd = dfilt.df1
hd = dfilt.df1
returns
a default discretetime, directform I filter object that uses doubleprecision
arithmetic. By default, the numerator and denominator coefficients
b and a are set to 1. With these coefficients the filter passes the
input to the output without changes.
Make this filter a fixedpoint or singleprecision filter by
changing the value of the Arithmetic
property
for the filter hd
as follows:
To change to singleprecision filtering, enter
set(hd,'arithmetic','single');
To change to fixedpoint filtering, enter
set(hd,'arithmetic','fixed');
For more information about the property Arithmetic
,
refer to Arithmetic.
a(1)
, the leading denominator coefficient,
cannot be 0. To allow you to change the arithmetic setting to fixed
or single
, a(1)
must
be equal to 1.
The following figure shows the signal flow for the directform
I filter implemented by dfilt.df1
. To help you
see how the filter processes the coefficients, input, output, and
states of the filter, as well as numerical operations, the figure
includes the locations of the arithmetic and data type format elements
within the signal flow.
To help you understand where and how the filter performs fixedpoint arithmetic during filtering, the figure shows various labels associated with data and functional elements in the filter. The following table describes each label in the signal flow and relates the label to the filter properties that are associated with it.
The labels use a common format — a prefix followed by the word “format.” In this use, “format” means the word length and fraction length associated with the filter part referred to by the prefix.
For example, the InputFormat label refers to the word length
and fraction length used to interpret the data input to the filter.
The format properties InputWordLength
and InputFracLength
(as
shown in the table) store the word length and the fraction length
in bits. Or consider NumFormat, which refers to the word and fraction
lengths (CoeffWordLength
, NumFracLength
)
associated with representing filter numerator coefficients.
Signal Flow Label  Corresponding Word Length Property  Corresponding Fraction Length Property  Related Properties 

DenAccumFormat 



DenFormat 



DenProdFormat 



InputFormat 

 None 
NumAccumFormat 



NumFormat 



NumProdFormat 



OutputFormat 



Most important is the label position in the diagram, which identifies where the format applies.
As one example, look at the label DenProdFormat, which always
follows a denominator coefficient multiplication element in the signal
flow. The label indicates that denominator coefficients leave the
multiplication element with the word length and fraction length associated
with product operations that include denominator coefficients. From
reviewing the table, you see that the DenProdFormat refers to the
properties ProdWordLength
, ProductMode
and DenProdFracLength
that
fully define the denominator format after multiply (or product) operations.
In this table you see the properties associated with df1 implementations
of dfilt
objects.
The table lists all the properties that a filter can have. Many
of the properties are dynamic, meaning they exist only in response
to the settings of other properties. You might not see all of the
listed properties all the time. To view all the properties for a filter
at any time, use get(hd)
where hd
is
a filter.
For further information about the properties of this filter
or any dfilt
object, refer to FixedPoint Filter Properties.
Property Name  Brief Description 

 Determines how the accumulator outputs stored values.
Choose from full precision ( 
 Sets the word length used to store data in the accumulator/buffer. 
 Defines the arithmetic the filter uses. Gives you the
options 
 Specifies whether to cast numeric data to the appropriate accumulator format (as shown in the signal flow diagrams) before performing sum operations. 
 Specifies whether the filter automatically chooses the
proper fraction length to represent filter coefficients without overflowing.
Turning this off by setting the value to 
 Specifies the word length to apply to filter coefficients. 
 Specifies the fraction length the filter algorithm uses
to interpret the results of product operations involving denominator
coefficients. You can change the value for this property when you
set 
 Set the fraction length the filter uses to interpret
denominator coefficients. 
 Stores the denominator coefficients for the IIR filter. 
 Specifies how the filter algorithm interprets the results
of product operations involving denominator coefficients. You can
change this property value when you set 
 Describes the signal flow for the filter object, including all of the active elements that perform operations during filtering — gains, delays, sums, products, and input/output. 
 Specifies the fraction length the filter uses to interpret input data. 
 Specifies the word length applied to interpret input data. 
 Specifies how the filter algorithm interprets the results
of addition operations involving numerator coefficients. You can change
the value of this property after you set 
 Holds the numerator coefficient values for the filter. 
 Sets the fraction length used to interpret the value of numerator coefficients. 
 Specifies how the filter algorithm interprets the results
of product operations involving numerator coefficients. Available
to be changed when you set 
 Determines how the filter interprets the filter output
data. You can change the value of 
 Determines the word length used for the output data. 
 Sets the mode used to respond to overflow conditions
in fixedpoint arithmetic. Choose from either 
 Determines how the filter handles the output of product
operations. Choose from full precision ( 
 Specifies the word length to use for multiplication operation
results. This property becomes writable (you can change the value)
when you set 
 Specifies whether to reset the filter states and memory
before each filtering operation. Lets you decide whether your filter
retains states from previous filtering runs. 
 Sets the mode the filter uses to quantize numeric values when the values lie between representable values for the data format (word and fraction lengths).
The choice you make affects only the accumulator and output arithmetic. Coefficient and input arithmetic always round. Finally, products never overflow — they maintain full precision. 
 Specifies whether the filter uses signed or unsigned fixedpoint coefficients. Only coefficients reflect this property setting. 
 This property contains the filter states before, during,
and after filter operations. States act as filter memory between filtering
runs or sessions. The states use 
Specify a secondorder directform I structure for a dfilt
object, hd
,
with the following code:
b = [0.3 0.6 0.3]; a = [1 0 0.2]; hd = dfilt.df1(b,a); % Convert hd to fixedpoint filter set(hd,'arithmetic','fixed')
dfilt
 dfilt.df1t
 dfilt.df2
 dfilt.df2t