This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

dsp.FIRRateConverter System object

Package: dsp

Sample rate converter


The FIRRateConverter 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 interpolator upsamples the input by the upsampling factor, L, followed by a lowpass FIR filter. The FIR filter acts both as an anti-imaging filter and an anti-aliasing filter prior to decimation. The decimator downsamples the output of upsampling and FIR filtering by the downsampling factor M. You must use upsampling and downsampling factors that are relatively prime, or coprime. The resulting discrete-time signal has a sampling rate L/M times the original sampling rate.

To perform sampling rate conversion:

  1. Define and set up your FIR sample rate converter. See Construction.

  2. Call step to perform sampling rate conversion according to the properties of dsp.FIRRateConverter. 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.


H = dsp.FIRRateConverter returns a FIR sample rate converter, H, that resamples an input signal at a rate 3/2 times the original sampling rate.

H = dsp.FIRRateConverter('PropertyName',PropertyValue, ...) returns an FIR sample rate converter, H, with each property set to the specified value.

H = dsp.FIRRateConverter(L,M,NUM,'PropertyName', PropertyValue, ...) returns an FIR sample rate converter, H, with the InterpolationFactor property set to L, the DecimationFactor property set to M, the Numerator property set to NUM, and other specified properties set to the specified values.



Interpolation factor

Specify the integer upsampling factor. The default is 3.


Decimation factor

Specify the integer downsampling factor. The default is 2.


FIR filter coefficients

Specify the FIR filter coefficients in powers of z-1. The length of filter coefficients must exceed the interpolation factor. Use a lowpass with normalized cutoff frequency no greater than min(1/InterpolationFactor, 1/DecimationFactor). All initial filter states are zero. The default is firpm(70,[0 0.28 0.32 1],[1 1 0 0]).

 Fixed-Point Properties


cloneCreate FIR sample rate convertor object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset states of FIR sample rate converter
stepResample input with FIR rate converter


expand all

This example shows how to resample a 100 Hz sine wave signal by a factor of 3: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).

hsin = dsp.SineWave(1, 100,'SampleRate', 5000,'SamplesPerFrame', 50);

Create a FIR rate converter filter. The default interpolation factor is 3 and decimation factor is 2.

hfirrc = dsp.FIRRateConverter;
input = hsin();
output = hfirrc(input);

Plot the original and resampled signals.

ndelay = round(length(hfirrc.Numerator)/2/hfirrc.DecimationFactor);
indx = ndelay+1:length(output);
x = (0:length(indx)-1)/hsin.SampleRate*hfirrc.DecimationFactor/hfirrc.InterpolationFactor;
stem((0:38)/hsin.SampleRate, input(1:39)); hold on;
stem(x, hfirrc.InterpolationFactor*output(indx),'r');

This example shows how to resample and play an audio signal from 48 kHz to 32 kHz on a Windows® platform.

hmfr = dsp.AudioFileReader('audio48kHz.wav', ...
    'OutputDataType', 'single', ...
    'SamplesPerFrame', 300);
hap = audioDeviceWriter(32000);

Create an FIRRateConverter System object with interpolation factor = 2, decimation factor = 3. Default FIR filter coefficients define a lowpass filter with normalized cutoff frequency of 1/3.

hfirrc = dsp.FIRRateConverter(2,3);

while ~isDone(hmfr)
    audio1 = step(hmfr);
    audio2 = step(hfirrc, audio1);
    step(hap, audio2);



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

Introduced in R2012a

Was this topic helpful?