dfilt.scalar - Discrete-time, scalar filter

Syntax

Refer to dfilt.scalar in Signal Processing Toolbox™ documentation.

Description

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:

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.

Properties

In this table you see the properties associated with the scalar implementation of dfilt objects.

For further information about the properties of this filter or any dfilt object, refer to Fixed-Point Filter Properties.

Property Name

Brief Description

Arithmetic

Defines the arithmetic the filter uses. Gives you the options double, single, and fixed. In short, this property defines the operating mode for your filter.

CastBeforeSum

Specifies whether to cast numeric data to the appropriate accumulator format (as shown in the signal flow diagrams) before performing sum operations.

CoeffAutoScale

Specifies whether the filter automatically chooses the proper fraction length to represent filter coefficients without overflowing. Turning this off by setting the value to false enables you to change the CoeffFracLength property to specify the precision used.

CoeffFracLength

Set the fraction length the filter uses to interpret coefficients. CoeffFracLength is always available, but it is read-only until you set CoeffAutoScale to false.

CoeffWordLength

Specifies the word length to apply to filter coefficients.

FilterStructure

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.

Gain

Returns the gain for the scalar filter. Scalar filters do not alter the input data except by adding gain.

InputFracLength

Specifies the fraction length the filter uses to interpret input data.

InputWordLength

Specifies the word length applied to interpret input data.

OutputFracLength

Determines how the filter interprets the filter output data. You can change the value of OutputFracLength when you set OutputMode to SpecifyPrecision.

OutputMode

Sets the mode the filter uses to scale the filtered data for output. You have the following choices:

  • AvoidOverflow — directs the filter to set the output data word length and fraction length to avoid causing the data to overflow.

  • BestPrecision — directs the filter to set the output data word length and fraction length to maximize the precision in the output data.

  • SpecifyPrecision — lets you set the word and fraction lengths used by the output data from filtering.

OutputWordLength

Determines the word length used for the output data.

OverflowMode

Sets the mode used to respond to overflow conditions in fixed-point arithmetic. Choose from either saturate (limit the output to the largest positive or negative representable value) or wrap (set overflowing values to the nearest representable value using modular arithmetic). The choice you make affects only the accumulator and output arithmetic. Coefficient and input arithmetic always saturates. Finally, products never overflow — they maintain full precision.

PersistentMemory

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. False is the default setting.

RoundMode

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).

  • convergent — Round up to the next allowable quantized value.

  • ceil — Round to the nearest allowable quantized value. Numbers that are exactly halfway between the two nearest allowable quantized values are rounded up only if the least significant bit (after rounding) would be set to 1.

  • fix — Round negative numbers up and positive numbers down to the next allowable quantized value.

  • floor — Round down to the next allowable quantized value.

  • round — Round to the nearest allowable quantized value. Numbers that are halfway between the two nearest allowable quantized values are rounded up.

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.

Signed

Specifies whether the filter uses signed or unsigned fixed-point coefficients. Only coefficients reflect this property setting.

States

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 fi objects, with the associated properties from those objects. For details, refer to filtstates in Signal Processing Toolbox documentation or in the Help system.

Example

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(hd_gain,hd_filt)
fvtool(hd_filt,hd_gain,hd)
hd_filt = 
         FilterStructure: 'direct-form I'
              Arithmetic: 'double'
               Numerator: [0.3000 0.6000 0.3000]
             Denominator: [1 0 0.2000]
        PersistentMemory: false
                  States: [4x1 double]

hd_gain = 
         FilterStructure: 'Scalar'
              Arithmetic: 'double'
                    Gain: 3
        PersistentMemory: false
                  States: []
hd = 
         FilterStructure: Cascade
              Section(1): Scalar
              Section(2): Direct Form I
        PersistentMemory: false

To view the sections of the cascaded filter, use

hd.section(1)
 
ans = 
         FilterStructure: 'Scalar'
              Arithmetic: 'double'
                    Gain: 3
        PersistentMemory: false
                  States: []

and

hd.section(2)
 
ans = 
         FilterStructure: 'Direct Form I'
              Arithmetic: 'double'
               Numerator: [0.3000 0.6000 0.3000]
             Denominator: [1 0 0.2000]
        PersistentMemory: false
                  States: [4x1 double]

See Also

dfilt, dfilt.cascade

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS