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.SampleRateConverter System object

Multistage sample rate converter


The SampleRateConverter System object™ converts the sample rate of an incoming signal.

To convert the sample rate of a signal:

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

  2. Call step to convert the sample rate according to the properties of dsp.SampleRateConverter. The behavior of step is specific to each object in the toolbox.


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.


src = dsp.SampleRateConverter creates a multistage FIR sample rate converter System object, src, that converts the sample rate of each channel of an input signal.

src = dsp.SampleRateConverter(Name,Value) returns a multistage FIR sample rate converter System object, src, with properties and options specified by one or more Name,Value pair arguments.


expand all

Specify the two-sided bandwidth of interest (after rate conversion) as a positive scalar expressed in hertz. This property is the two-sided bandwidth of the information-carrying portion of the signal that you wish to retain. The default is 40 kHz.

Specify the sample rate of the input signal as a positive scalar expressed in hertz. The input sample rate must be greater than the bandwidth of interest. The default is 192 kHz.

Specify the maximum allowed tolerance for the sample rate of the output signal as a positive scalar between 0 and 1. The default is 0.

The output rate tolerance allows for a simpler design in many cases. The actual output sample rate varies but is within the specified range. For example, if OutputRateTolerance is specified as 0.01, then the actual output sample rate is in the range given by OutputSampleRate ± 1%.

Specify the sample rate of the output signal as a positive scalar expressed in hertz. The output sample rate must be greater than the bandwidth of interest. The default is 44.1 kHz.

Specify the stopband attenuation as a positive scalar expressed in decibels. This property is the minimum amount by which any aliasing involved in the process is attenuated. The default is 80 dB.


costCompute implementation cost
freqzFrequency response
getActualOutputRateGet actual output rate
getFiltersObtain single-stage filters
getRateChangeFactorsOverall interpolation and decimation factors
infoDisplay information about sample rate converter
resetReset internal states of multistage sample rate converter
stepConvert sample rate of signal
visualizeFilterStagesVisualize filter stages
Common to All System Objects

Create System object with same property values


Expected number of inputs to a System object


Expected number of outputs of a System object


Check locked states of a System object (logical)


Allow System object property value changes


expand all

Convert the sample rate of an audio signal from 44.1 kHz (CD quality) to 96 kHz (DVD quality).

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

fs1 = 44.1e3;
fs2 = 96e3;

SRC = dsp.SampleRateConverter('Bandwidth',40e3,...

[L,M] = getRateChangeFactors(SRC);
FrameSize = 10*M;

AR = dsp.AudioFileReader('guitar10min.ogg', ...
AW = dsp.AudioFileWriter('guitar10min_96k.wav', ...

Run the system for 15 s. Release all objects.

while toc < 15
    x = AR();
    y = SRC(x);


Plot the input and output signals. Use a different set of axes for each signal. Shift the output to compensate for the delay introduced by the filter.

t1 = 0:1/fs1:1/30-1/fs1;
t2 = 0:1/fs2:1/30-1/fs2;

delay = 114;

el1 = 1:length(t1)-delay;

el2 = 1:length(t2);
el2(1:delay) = [];

hold on

hold on
xlabel('Time (s)')

Zoom in to see the difference in sample rates. Use a different set of axes for each channel.


hold on
xlim([0.01 0.0103])
title('First channel')

hold on
xlim([0.01 0.0103])
xlabel('Time (s)')
title('Second channel')

A signal output from an A/D converter is sampled at 98.304 MHz. The signal has a bandwidth of 20 MHz. Reduce the sample rate of the signal to 22 MHz, which is the bandwidth of 802.11 channels. Make the conversion exactly and then redo it with an output rate tolerance of 1%.

SRC1 = dsp.SampleRateConverter('Bandwidth',20e6, ...
    'InputSampleRate',98.304e6,'OutputSampleRate',22e6, ...
SRC2 = dsp.SampleRateConverter('Bandwidth',20e6, ...
    'InputSampleRate',98.304e6,'OutputSampleRate',22e6, ...

Use the cost method to determine the cost of each sample rate conversion. The zero-tolerance process requires more than 500 times as many coefficients as the 1% process.

c1 = cost(SRC1)
c2 = cost(SRC2)
c1 = 

  struct with fields:

                  NumCoefficients: 84779
                        NumStates: 133
    MultiplicationsPerInputSample: 27.0422
          AdditionsPerInputSample: 26.0684

c2 = 

  struct with fields:

                  NumCoefficients: 150
                        NumStates: 127
    MultiplicationsPerInputSample: 22.6667
          AdditionsPerInputSample: 22.1111

Find the integer upsampling and downsampling factors used in each conversion.

[L1,M1] = getRateChangeFactors(SRC1)
[L2,M2] = getRateChangeFactors(SRC2)
L1 =


M1 =


L2 =


M2 =


Compute the actual sample rate of the output signal when the sample rate conversion has a tolerance of 1%.

ans =



  • The general multistage sample rate converter performs a multistage decimation, a single-stage sample rate conversion, and a multistage interpolation, in that order. Actual designs include at most two of those steps.

  • The procedure determines automatically the optimal number of decimation or interpolation stages. In special cases, the decimation or the interpolation can be performed in a single stage.

  • The algorithm always attempts to start by reducing the sample rate. This decreases the amount of computation required. The decimation step is designed so that no intermediate sample rate goes below the bandwidth of interest. This ensures that no information is filtered out.

  • Each individual stage uses halfband or Nyquist filters to minimize the number of nonzero coefficients.

  • Transition-band aliasing is allowed because it decreases the implementation cost. The signal within the bandwidth of interest is kept alias free up to the value specified by the StopbandAttenuation property.

Extended Capabilities

Introduced in R2014b

Was this topic helpful?