Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# dfilt.latticemamin

Discrete-time, lattice, moving-average filter with minimum phase

## Synopsis

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

## Description

hd = dfilt.latticemamin(k) returns a discrete-time, lattice, moving-average, minimum phase, filter object hd, with lattice coefficients k.

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');`

 Note   When the k coefficients define a minimum phase filter, the resulting filter in this structure is minimum phase. When your coefficients do not define a minimum phase filter, placing them in this structure does not produce a minimum phase filter.

hd = dfilt.latticemamin returns a default discrete-time, lattice, moving-average, minimum phase, filter object hd, with k=[ ]. This filter passes the input through to the output unchanged.

## Fixed-Point Filter Structure

The following figure shows the signal flow for the minimum phase implementation of a moving-average lattice filter implemented by dfilt.latticemamin. 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.

### Notes About the Signal Flow Diagram

To help you understand where and how the filter performs fixed-point 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

AccumFormat

AccumWordLength

AccumFracLength

AccumMode

InputFormat

InputWordLength

InputFracLength

None

LatticeFormat

CoeffWordLength

LatticeFracLength

CoeffAutoScale

OutputFormat

OutputWordLength

OutputFracLength

OutputMode

ProductFormat

ProductWordLength

ProductFracLength

ProductMode

StateFormat

StateWordLength

StateFracLength

States

Most important is the label position in the diagram, which identifies where the format applies.

As one example, look at the label ProductFormat, 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 ProductFormat refers to the properties ProductFracLength, ProductWordLength, and ProductMode that fully define the coefficient format after multiply (or product) operations.

## Properties

In this table you see the properties associated with the minimum phase, moving average lattice 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

AccumFracLength

Specifies the fraction length used to interpret data output by the accumulator. This is a property of FIR filters and lattice filters. IIR filters have two similar properties — DenAccumFracLength and NumAccumFracLength — that let you set the precision for numerator and denominator operations separately.

AccumMode

Determines how the accumulator outputs stored values. Choose from full precision (FullPrecision), or whether to keep the most significant bits (KeepMSB) or least significant bits (KeepLSB) when output results need shorter word length than the accumulator supports. To let you set the word length and the precision (the fraction length) used by the output from the accumulator, set AccumMode to SpecifyPrecision.

AccumWordLength

Sets the word length used to store data in the accumulator/buffer.

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 LatticeFracLength property to specify the precision used.

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.

InputFracLength

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

InputWordLength

Specifies the word length applied to interpret input data.

Lattice

Any lattice structure coefficients.

LatticeFracLength

Sets the fraction length applied to the lattice coefficients.

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.

ProductFracLength

For the output from a product operation, this sets the fraction length used to interpret the data. This property becomes writable (you can change the value) when you set ProductMode to SpecifyPrecision.

ProductMode

Determines how the filter handles the output of product operations. Choose from full precision (FullPrecision), or whether to keep the most significant bit (KeepMSB) or least significant bit (KeepLSB) in the result when you need to shorten the data words. For you to be able to set the precision (the fraction length) used by the output from the multiplies, you set ProductMode to SpecifyPrecision.

ProductWordLength

Specifies the word length to use for multiplication operation results. This property becomes writable (you can change the value) when you set ProductMode to SpecifyPrecision.

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

• ceil - Round toward positive infinity.

• convergent - Round to the closest representable integer. Ties round to the nearest even stored integer. This is the least biased of the methods available in this software.

• fix - Round toward zero.

• floor - Round toward negative infinity.

• nearest - Round toward nearest. Ties round toward positive infinity.

• round - Round toward nearest. Ties round toward negative infinity for negative numbers, and toward positive infinity for positive numbers.

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.

StateFracLength

When you set StateAutoScale to false, you enable the StateFracLength property that lets you set the fraction length applied to interpret the filter states.

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.

StateWordLength

Sets the word length used to represent the filter states.

## Examples

Specify a third-order lattice, moving-average, minimum phase, filter structure for a dfilt object, hd, with the following code:

```k = [.66 .7 .44];
hd = dfilt.latticemamin(k);```