Discretetime, directform FIR filter
hd = dfilt.dffir(b)
hd = dfilt.dffir
hd = dfilt.dffir(b)
returns
a discretetime, directform finite impulse response (FIR) filter
object hd
, with numerator coefficients b
.
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.
hd = dfilt.dffir
returns
a default, discretetime, directform FIR filter object hd
,
with b=1
. This filter passes the input through
to the output unchanged.
The following figure shows the signal flow for the directform
FIR filter implemented by dfilt.dffir
. To help
you see how the filter processes the coefficients, input, and states
of the filter, as well as numerical operations, the figure includes
the locations of the formatting objects 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 letters“frmt” (format). In this use, “frmt” indicates the word length and fraction length associated with the filter part referred to by the prefix.
For example, the InputFrmt 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 NumFrmt, 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 

AccumFrmt 

 None 
InputFrmt 

 None 
NumFrmt 



OutputFrmt 

 None 
ProductFrmt 

 None 
Most important is the label position in the diagram, which identifies where the format applies.
As one example, look at the label ProductFrmt, which always
follows a coefficient multiplication element in the signal flow. The
label indicates that coefficients leave the multiplication element
with the word length and fraction length associated with product operations
that include coefficients. From reviewing the table, you see that
the ProductFrmt refers to the properties ProductFracLength
and ProductWordLength
that
fully define the coefficient format after multiply (or product) operations.
In this table you see the properties associated with directform
FIR implementation of dfilt
objects.
Note
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.
Name  Values  Description 

 Any positive or negative integer number of bits [30]  Specifies the fraction length used to interpret data output by the accumulator. 
 Any integer number of bits[34]  Sets the word length used to store data in the accumulator. 
 fixed for fixedpoint filters  Setting this to 
 [true], false  Specifies whether the filter automatically chooses the
proper fraction length to represent filter coefficients without overflowing.
Turning this off by setting the value to 
 Any integer number of bits [16]  Specifies the word length to apply to filter coefficients. 
 [FullPrecision], SpecifyPrecision  Controls whether the filter automatically sets the output
word and fraction lengths, product word and fraction lengths, and
the accumulator word and fraction lengths to maintain the best precision
results during filtering. The default value, 
 Any positive or negative integer number of bits [15]  Specifies the fraction length the filter uses to interpret input data. 
 Any integer number of bits [16]  Specifies the word length applied to interpret input data. 
 Any positive or negative integer number of bits [  Sets the fraction length used to interpret the numerator coefficients. 
 Any positive or negative integer number of bits [32]  Determines how the filter interprets the filter output
data. You can change the value of 
 Any integer number of bits [39]  Determines the word length used for the output data.
You make this property editable by setting 
 saturate, [wrap]  Sets the mode used to respond to overflow conditions
in fixedpoint arithmetic. Choose from either 
 Any positive or negative integer number of bits [  Specifies the fraction length to use for multiplication
operation results. This property becomes writable (you can change
the value) when you set 
 Any integer number of bits [32]  Specifies the word length to use for multiplication operation
results. This property becomes writable (you can change the value)
when you set 
 [  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. 
 [true], false  Specifies whether the filter uses signed or unsigned fixedpoint coefficients. Only coefficients reflect this property setting. 

 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 FIR filter structure for
a dfilt
object hd
, with the
following code that constructs the filter in doubleprecision format
and then converts the filter to fixedpoint operation:
b = [0.05 0.9 0.05]; hd = dfilt.dffir(b); % Create fixedpoint filter hd.arithmetic='fixed'; % Change FilterInternals property to % SpecifyPrecision enabling other properties hd.FilterInternals='SpecifyPrecision';