# dsp.FIRRateConverter

Sample rate converter

## Description

The `dsp.FIRRateConverter`

System object™ performs sampling rate conversion by a rational factor on a vector or matrix
input. The FIR rate converter cascades an interpolator with a decimator. The rate converter
(as shown in the schematic) conceptually consists of an upsampler, followed by a combined
anti-imaging and anti-aliasing FIR filter, followed by a downsampler. The coefficients of the
anti-imaging and anti-aliasing FIR filter can be specified through the
`Numerator`

property, or can be automatically designed by the object
using the `designMultirateFIR`

function. For an example, see
Resample Signal Using FIR Rate Converter.

The upsampler increases the sample rate of the signal by a factor *L* and
the downsampler reduces the sample rate of the signal by a factor *M*. Use
upsampling and downsampling factors that are relatively prime or coprime. The resulting
discrete-time signal has a sample rate that is *L/M* times the original
sample rate.

Note that the actual object algorithm implements a polyphase structure, an efficient equivalent of the combined system depicted in the diagram. For more details, see Algorithms.

To perform sampling rate conversion:

Create the

`dsp.FIRRateConverter`

object and set its properties.Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

## Creation

### Syntax

### Description

returns an FIR
sample rate converter object with an interpolation factor of 3 and a decimation factor of
2. The object designs the FIR filter coefficients using the
`firrc`

= dsp.FIRRateConverter`designMultirateFIR(3,2)`

function.

returns an FIR sample rate converter with the integer-valued
`firrc`

= dsp.FIRRateConverter(`L`

,`M`

)`InterpolationFactor`

property set to `L`

and the
`DecimationFactor`

property set to `M`

. The object
designs its filter coefficients based on the rate conversion factors that you specify
while creating the object, using the `designMultirateFIR(L,M)`

function. The designed filter corresponds to a lowpass filter with normalized cutoff
frequency no greater than `min(π/L,π/M)`

in radial frequency
units.

returns an FIR sample rate converter where the `firrc`

= dsp.FIRRateConverter(`L`

,`M`

,`'Auto'`

)`NumeratorSource`

property is set to `'Auto'`

. In this mode, every time there is an
update in the rate conversion factors, the object redesigns the filter using the design
method specified in `DesignMethod`

.

returns an FIR sample rate converter with the `firrc`

= dsp.FIRRateConverter(`L`

,`M`

,`num`

)`Numerator`

property set
to `num`

.

returns an FIR sample rate converter with the `firrc`

= dsp.FIRRateConverter(`L`

,`M`

,`method`

)`DesignMethod`

property
set to `method`

. When you pass the design method as an input, the
`NumeratorSource`

property is automatically set to
`'Auto'`

.

returns an FIR sample rate converter with each specified property set to the specified
value. Enclose each property name in quotes. You can use this syntax with any previous
input argument combinations.`firrc`

= dsp.FIRRateConverter(___,`Name,Value`

)

**Example: **```
firrc =
dsp.FIRRateConverter('FullPrecisionOverride','false')
```

enables the fixed-point
data types to be controlled through the individual fixed-point property
settings.

returns an FIR sample rate converter where the filter coefficients are designed using
`firrc`

= dsp.FIRRateConverter(`L`

,`M`

,`'legacy'`

)`firpm(70,[0 0.28 0.32 1],[1 1 0 0])`

. The designed filter has a
cutoff frequency of π/3 radians/sample.

## Properties

## Usage

### Syntax

### Input Arguments

### Output Arguments

## Object Functions

To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named `obj`

, use
this syntax:

release(obj)

## Examples

## Algorithms

The FIR rate converter is implemented efficiently using a polyphase structure.

To derive the polyphase structure, start with the transfer function of the FIR filter: This FIR filter is a combined anti-imaging and anti-aliasing filter.

$$H(z)={b}_{0}+{b}_{1}{z}^{-1}+\mathrm{...}+{b}_{N}{z}^{-N}$$

*N*+1 is the length of the FIR filter.

You can rearrange this equation as follows:

$$H(z)=\begin{array}{c}\left({b}_{0}+{b}_{L}{z}^{-L}+{b}_{2L}{z}^{-2L}+\mathrm{..}+{b}_{N-L+1}{z}^{-(N-L+1)}\right)+\\ {z}^{-1}\left({b}_{1}+{b}_{L+1}{z}^{-L}+{b}_{2L+1}{z}^{-2L}+\mathrm{..}+{b}_{N-L+2}{z}^{-(N-L+1)}\right)+\\ \begin{array}{c}\vdots \\ {z}^{-(L-1)}\left({b}_{L-1}+{b}_{2L-1}{z}^{-L}+{b}_{3L-1}{z}^{-2L}+\mathrm{..}+{b}_{N}{z}^{-(N-L+1)}\right)\end{array}\end{array}$$

*L* is the number of polyphase components, and its value
equals the interpolation factor that you specify.

You can write this equation as:

$$H(z)={E}_{0}({z}^{L})+{z}^{-1}{E}_{1}({z}^{L})+\mathrm{...}+{z}^{-(L-1)}{E}_{L-1}({z}^{L})$$

*E _{0}(z^{L})*,

*E*, ...,

_{1}(z^{L})*E*are polyphase components of the FIR filter

_{L-1}(z^{L})*H*(z).

Conceptually, the FIR rate converter contains an upsampler, followed by a combined
anti-imaging, anti-aliasing FIR filter *H*(z), which is followed by a downsampler.

Replace *H*(z) with its polyphase representation.

Here is the multirate noble identity for interpolation.

Applying the noble identity for interpolation moves the upsampling operation to after the filtering operation. This move enables you to filter the signal at a lower rate.

You can replace the upsampling operator, delay block, and the adder with a commutator
switch. To account for the downsampler that follows, the switch moves in steps of size
*M*. The switch receives the first sample from branch 0 and moves in
the counter clockwise direction, each time skipping *M*−1 branches.

As an example, consider a rate converter with *L* set to 5 and
*M* set to 3. The polyphase components are
*E _{0}(z)*,

*E*,

_{1}(z)*E*,

_{2}(z)*E*, and

_{3}(z)*E*. The switch starts on the first branch 0, skips branches 1 and 2, receives the next sample from branch 3, then skips branches 4 and 0, receives the next sample from branch 2, and so on. The sequence of branches from which the switch receives the data sample is [0, 3, 1, 4, 2, 0, 3, 1, ….].

_{4}(z)The rate converter implements the *L*/*M* conversion by
first applying the interpolation factor *L* to the incoming data, and using
the commutator switch at the end to receive only 1 in *M* samples,
effectively accounting for the dowsampling factor *M*. Hence, the sample
rate at the output of the FIR rate converter is *Lfs/M*.

## Extended Capabilities

## Version History

**Introduced in R2012a**