Discrete-time, scalar filter
dfilt.scalar(g)
dfilt.scalar
dfilt.scalar(g)
returns
a discrete-time, scalar filter object with gain g
,
where g
is a scalar.
Make this filter a fixed-point or single-precision filter by
changing the value of the Arithmetic
property
for the filter hd
as follows:
To change to single-precision filtering, enter
set(hd,'arithmetic','single');
To change to fixed-point filtering, enter
set(hd,'arithmetic','fixed');
For more information about the property Arithmetic
,
refer to Arithmetic.
dfilt.scalar
returns a
default, discrete-time scalar gain filter object hd
,
with gain 1
.
In this table you see the properties associated with the scalar
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 Fixed-Point Filter Properties.
Property Name | Brief Description |
---|---|
| 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 |
| Set the fraction length the filter uses to interpret
coefficients. |
| Specifies the word length to apply to filter coefficients. |
| 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. |
| Returns the gain for the scalar filter. Scalar filters do not alter the input data except by adding gain. |
| Specifies the fraction length the filter uses to interpret input data. |
| Specifies the word length applied to interpret input data. |
| Determines how the filter interprets the filter output
data. You can change the value of |
| Sets the mode the filter uses to scale the filtered data for output. You have the following choices:
|
| Determines the word length used for the output data. |
| Sets the mode used to respond to overflow conditions
in fixed-point arithmetic. Choose from either |
| 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 fixed-point 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 |
Create a direct-form I filter object hd_filt
and
a scalar object with a gain of 3 hd_gain
and cascade
them together.
b = [0.3 0.6 0.3]; a = [1 0 0.2]; hd_filt = dfilt.df1(b,a); hd_gain = dfilt.scalar(3); hd_cascade=cascade(hd_gain,hd_filt); fvtool_handle = fvtool(hd_filt,hd_gain,hd_cascade); legend(fvtool_handle,'IIR Filter (direct form I)',... 'Gain','Cascaded Filter');
To view the stages of the cascaded filter, use
hd.Stage(1)
and
hd.Stage(2)