# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# dsp.FIRDecimator System object

Package: dsp

Polyphase FIR decimator

## Description

The `FIRDecimator` object resamples vector or matrix inputs along the first dimension. The object reseamples at a rate M times slower than the input sampling rate, where M is the integer-valued downsampling factor. The decimation combines an FIR anti-aliasing filter with downsampling. The FIR decimator object uses a polyphase implementation of the FIR filter.

To resample vector or matrix inputs along the first dimension:

1. Define and set up your FIR decimator. See Construction.

2. Call `step` to resample the vector or matrix inputs according to the properties of `dsp.FIRDecimator`. The behavior of `step` is specific to each object in the toolbox.

 Note:   Starting in R2016b, instead of using the `step` method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, ```y = step(obj,x)``` and `y = obj(x)` perform equivalent operations.

## Construction

`firdecim = dsp.FIRDecimator` returns an FIR decimator, `firdecim`, which applies an FIR filter with a cutoff frequency of `0.4*pi` radians/sample to the input and downsamples the filter output by factor of 2. This System object supports variable-size input.

```firdecim = dsp.FIRDecimator ('PropertyName',PropertyValue, ...) ``` returns an FIR decimator, `firdecim`, with each property set to the specified value.

```firdecim = dsp.FIRDecimator(DECIM, NUM, 'PropertyName',PropertyValue, ...)``` returns an FIR decimator, `firdecim`, with the integer-valued `DecimationFactor` property set to `DECIM`, the `Numerator` property set to `NUM`, and other specified properties set to the specified values.

## Properties

 `DecimationFactor` Decimation factor Specify the downsampling factor as a positive integer. The FIR decimator reduces the sampling rate of the input by this factor. The size of the input along the first dimension must be a multiple of the decimation factor. The default is `2`. `NumeratorSource` FIR filter coefficient source Specify the source of the numerator coefficients as one of `'Property'` (default) or `'Input port'`. When you specify ```'Input port'```, the filter object requires the numerator coefficients to be specified as the third argument to every step. `Numerator` FIR filter coefficients Specify the numerator coefficients of the FIR filter in powers of z–1. The following equation defines the system function for a filter of length L:`$H\left(z\right)=\sum _{l=0}^{L-1}{b}_{l}{z}^{-l}$`To prevent aliasing as a result of downsampling, the filter transfer function should have a normalized cutoff frequency no greater than 1/`DecimationFactor`. You can specify the filter coefficients as a vector in the supported data types. The default is `fir1(35,0.4)`. `Structure` Filter structure Specify the implementation of the FIR filter as either `Direct form` or ```Direct form transposed```. The default is ```Direct form```.

## Methods

 freqz Frequency response fvtool Open filter visualization tool impz Impulse response phasez Unwrapped phase response reset Reset filter states of FIR decimator step Decimate input by integer factor
Common to All System Objects
`clone`

Create System object with same property values

`getNumInputs`

Expected number of inputs to a System object

`getNumOutputs`

Expected number of outputs of a System object

`isLocked`

Check locked states of a System object (logical)

`release`

Allow System object property value changes

## Examples

expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent `step` syntax. For example, myObject(x) becomes step(myObject,x).

This example shows how to decimate a sum of sine waves with angular frequencies of pi/4 and 2pi/3 radians/sample by a factor of two. To prevent aliasing, the FIR decimator filters out the 2pi/3 radians/sample component before downsampling.

```x = cos(pi/4*[0:95]')+sin(2*pi/3*[0:95]'); firdecim = dsp.FIRDecimator; y = firdecim(x); ```

View group delay of default FIR filter

```fvtool(fir1(35,0.4),1,'analysis','grpdelay'); ```

Group delay of the default linear-phase FIR filter is 17.5 samples. Downsampling by a factor of two expect an approx. 8.75 sample delay in the output y with the initial filter states of zero

```subplot(211); stem(x(1:length(x)/2),'b','markerfacecolor',[0 0 1]); title('Input Signal'); subplot(212); stem(y,'b','markerfacecolor',[0 0 1]); title('Output--Lowpass filtered and downsampled by 2'); ```

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent `step` syntax. For example, myObject(x) becomes step(myObject,x).

This example shows how to reduce the sampling rate of an audio signal by 1/2 and plays it.

```afr = dsp.AudioFileReader('OutputDataType',... 'single'); adw = audioDeviceWriter(22050/2); firdecim = dsp.FIRDecimator; while ~isDone(afr) frame = afr(); y = firdecim(frame); adw(y); end release(afr); pause(0.5); release(adw); ```

expand all

## Algorithms

This object implements the algorithm, inputs, and outputs described on the FIR Decimation block reference page. The object properties correspond to the block parameters, except:

• Framing – The FIR decimator object only supports `Maintain input frame rate`

• Output buffer initial conditions – The FIR decimator object does not support this parameter.

• Rate options – The FIR decimator object does not support this parameter.

• Input processing The FIR decimator object does not support this parameter.