Main Content

Sample rate converter

The `dsp.FIRRateConverter`

System object™ performs sampling rate conversion by a rational factor on a vector or matrix
input. The FIR rate convertor 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. To design an FIR filter
which acts as a combined anti-imaging and anti-aliasing FIR filter, use the `designMultirateFIR`

function. For an example, see Resample a 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?.

returns a FIR
sample rate converter, `firrc`

= dsp.FIRRateConverter`firrc`

, that resamples an input signal at a rate
3/2 times the original sampling rate.

returns an FIR sample rate converter, `firrc`

= dsp.FIRRateConverter(L,M,NUM)`firrc`

, with the
`InterpolationFactor`

property set to `L`

, the
`DecimationFactor`

property set to `M`

, and the `Numerator`

property set to `NUM`

.

returns an FIR sample rate converter, with additional properties specified by one or more
`firrc`

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

)`Name,Value`

pair arguments.

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

enables the fixed-point
data types to be controlled through the individual fixed-point property
settings.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)

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})*,

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)*,

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