# dfilt.dfsymfir

Discrete-time, direct-form symmetric FIR filter

## Syntax

```hd = dfilt.dfsymfir(b) hd = dfilt.dfsymfir ```

## Description

`hd = dfilt.dfsymfir(b)` returns a discrete-time, direct-form symmetric FIR filter object `hd`, with numerator coefficients `b`.

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.

`hd = dfilt.dfsymfir` returns a default, discrete-time, direct-form symmetric FIR filter object `hd`, with `b=1`. This filter passes the input through to the output unchanged.

Note

Only the coefficients in the first half of vector `b` are used because `dfilt.dfsymfir` assumes the coefficients in the second half are symmetric to those in the first half. In the following figure, for example, b(3) = 0, b(4) = b(2) and b(5) = b(1).

## Fixed-Point Filter Structure

In the following figure you see the signal flow diagram for the symmetric FIR filter that `dfilt.dfsymfir` implements. ### 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 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

`AccumWordLength`

`AccumFracLength`

None

InputFrmt

`InputWordLength`

`InputFracLength`

None

NumFrmt

`CoeffWordLength`

`NumFracLength`

`CoeffAutoScale`, `Signed`, `Numerator`

OutputFrmt

`OutputWordLength`

`OutputFracLength`

None

ProductFrmt

`ProductWordLength`

`ProductFracLength`

None

TapSumFrmt

`InputWordLength`

`InputFracLength`

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.

## Properties

In this table you see the properties associated with the symmetric 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 Fixed-Point Filter Properties.

Name

Values

Description

`AccumFracLength`

Any positive or negative integer number of bits 

Specifies the fraction length used to interpret data output by the accumulator.

`AccumWordLength`

Any integer number of bits

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

`Arithmetic`

fixed for fixed-point filters

Setting this to `fixed` allows you to modify other filter properties to customize your fixed-point filter.

`CoeffAutoScale`

[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 `false` enables you to change the `NumFracLength` property value to specify the precision used.

`CoeffWordLength`

Any integer number of bits 

Specifies the word length to apply to filter coefficients.

`FilterInternals`

[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, `FullPrecision`, sets automatic word and fraction length determination by the filter. `SpecifyPrecision` makes the output and accumulator-related properties available so you can set your own word and fraction lengths for them.

`InputFracLength`

Any positive or negative integer number of bits 

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

`InputWordLength`

Any integer number of bits 

Specifies the word length applied to interpret input data.

`NumFracLength`

Any positive or negative integer number of bits [`14`]

Sets the fraction length used to interpret the numerator coefficients.

`OutputFracLength`

Any positive or negative integer number of bits 

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

`OutputWordLength`

Any integer number of bits 

Determines the word length used for the output data. You make this property editable by setting `FilterInternals` to `SpecifyPrecision`.

`OverflowMode`

saturate, [wrap]

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`

Any positive or negative integer number of bits [`29`]

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

`ProductWordLength`

Any integer number of bits 

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

`RoundMode`

[`convergent`], `ceil`, `fix`, `floor`, `nearest`, `round`

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`

[true], false

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

`States`

`fi` object to match the filter arithmetic setting

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 fixed-point objects in Fixed-Point Designer™ documentation.

## Examples

### Odd Order

Specify a fifth-order direct-form symmetric FIR filter structure for a `dfilt` object `hd`, with the following code:

```b = [-0.008 0.06 0.44 0.44 0.06 -0.008]; hd = dfilt.dfsymfir(b); % Create fixed-point filter set(hd,'arithmetic','fixed') % Change FilterInternals property to % SpecifyPrecision hd.Filterinternals='SpecifyPrecision';```

### Even Order

Specify a fourth-order, fixed-point, direct-form symmetric FIR filter structure for a `dfilt` object `hd`, with the following code:

```b = [-0.01 0.1 0.8 0.1 -0.01]; hd = dfilt.dfsymfir(b); set(hd,'arithmetic','fixed');```