Main Content

dsp.IIRInterpolator

R2026b

Interpolate by arbitrary factor using polyphase IIR

Since R2026b

Description

The dsp.IIRInterpolator System object™ performs polyphase IIR interpolation of the input signal. The object implements a polyphase structure where each branch contains one or more allpass filter sections. The object determines the interpolation factor based on the number of branches in the polyphase structure.

To interpolate the input signal by a factor of 2, use either the dsp.IIRHalfbandInterpolator object or the dsp.IIRInterpolator object. The dsp.IIRHalfbandInterpolator object is optimized specifically for interpolation by a factor of 2. To interpolate the input signal by an arbitrary factor greater than or equal to 2, use the dsp.IIRInterpolator object.

The object algorithm implements an IIR polyphase structure, an efficient equivalent of the combined system depicted in the diagram. For more details, see Algorithms.

Conceptual diagram of IIR interpolation filter. Shows an upsampler followed by a lowpass IIR filter.

To interpolate the input signal:

  1. Create the dsp.IIRInterpolator object and set its properties.

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

Description

iirinterp = dsp.IIRInterpolator returns a polyphase IIR interpolator with the default settings. By default, the object has two branches and interpolates the signal by a factor of 2.

iirinterp = dsp.IIRInterpolator(Branches={Branch1,...,BranchL}) returns a polyphase IIR interpolator with L branches and an interpolation factor of L. For example, dsp.IIRInterpolator(Branches={dsp.AllpassFilter(AllpassCoefficients=0.3), dsp.AllpassFilter(AllpassCoefficients=0.5), dsp.AllpassFilter(AllpassCoefficients=0.7)}) creates an IIR interpolator with three branches and an interpolation factor of 3.

example

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Polyphase filter branches, specified as a cell array. The number of elements in the cell array determines the interpolation factor. Each element of the cell array can be one of these:

  • A dsp.AllpassFilter object

  • A dsp.FilterCascade object that exclusively contains dsp.AllpassFilter stages, for higher-order filtering in a single branch

This property is read-only.

Interpolation factor L, represented as a positive integer. The number of elements in the Branches property determines the value of this read-only property.

Data Types: double

Usage

Description

y = iirinterp(x) interpolates the input signal x using the polyphase IIR interpolation filter.

example

Input Arguments

expand all

Data input, specified as a column vector or a matrix. If the input is a matrix, the object treats each column as an independent channel.

This object supports variable-size input signals, which means that the number of rows in the input signal can change even when the object is locked. However, the number of channels (columns) must remain constant.

Data Types: single | double
Complex Number Support: Yes

Output Arguments

expand all

Interpolated output, returned as a column vector or a matrix. When the input is of size P-by-Q, the output is of size (P × L)-by-Q, where P is the number of input rows, L is the value of the InterpolationFactor property, and Q is the number of input columns.

The output has the same data type and complexity as the input signal.

Data Types: single | double
Complex Number Support: Yes

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)

expand all

freqzFrequency response of discrete-time filter System object
freqzmrCompute DTFT approximation of impulse response of multirate or single-rate filter
filterAnalyzerAnalyze filters with Filter Analyzer app
infoInformation about filter System object
costEstimate cost of implementing filter System object
coeffsReturns the filter System object coefficients in a structure
outputDelayDetermine output delay of single-rate or multirate filter
setInputSampleRateSpecify input sample rate in filter objects
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Create a polyphase IIR interpolator with two allpass branches and visualize its magnitude and phase response using the filterAnalyzer function.

Define two allpass filter branches. The first branch is a first-order allpass filter and the second branch is a second-order allpass filter.

branches = {dsp.AllpassFilter(AllpassCoefficients=0.1550), ...
    dsp.AllpassFilter(AllpassCoefficients=[0.3726 0.6536])};

Create the dsp.IIRInterpolator System object using the allpass branches. The interpolation factor equals the number of polyphase branches, which is two in this case.

iirInterp = dsp.IIRInterpolator(Branches=branches)
iirInterp = 
  dsp.IIRInterpolator with properties:

    InterpolationFactor: 2
               Branches: {[1×1 dsp.AllpassFilter]  [1×1 dsp.AllpassFilter]}

Visualize the frequency response of the IIR interpolator using the filterAnalyzer function.

filterAnalyzer(iirInterp)

Create a polyphase IIR interpolator, interpolate a sinusoidal signal, and use the outputDelay function to align the interpolated output with the original signal.

Define the allpass branches and create the dsp.IIRInterpolator System object.

branches = {dsp.AllpassFilter(AllpassCoefficients=0.1550), ...
    dsp.AllpassFilter(AllpassCoefficients=[0.3726 0.6536])};
iirInterp = dsp.IIRInterpolator(Branches=branches);
L = iirInterp.InterpolationFactor;

Generate a sinusoidal signal with a frequency of 50 Hz and a sample rate of 1000 Hz using the dsp.SineWave System object. Use a long signal so that the IIR filter transient settles before the region of interest.

fs = 1000;
sineGen = dsp.SineWave(Frequency=50,SampleRate=fs, ...
    SamplesPerFrame=2000,PhaseOffset=pi/2);
x = sineGen();

Interpolate the signal.

y = iirInterp(x);

Compute the output delay introduced by the IIR interpolator using the outputDelay function. Use the delay to align the output with the input for comparison.

delay = outputDelay(iirInterp,FsIn=fs,Fc=50)
delay = 
8.0327e-04

Plot the input and interpolated signals. Shift the output by the delay value so that the signals are aligned in time. Zoom into the steady-state region where the filter transient has settled. In the steady-state region, the interpolated output samples align with the input signal after compensating for the group delay.

fsOut = fs*L;
nInput = (0:length(x)-1)/fs;
tOutput = (0:length(y)-1)/fsOut - delay;
stem(tOutput,y,"filled",MarkerSize=4); hold on;
stem(nInput,x,MarkerSize=3); hold off;
xlim([0.02 0.08])
xlabel("Time (s)")
legend("Interpolated by " + L,"Input signal",Location="best");

Figure contains an axes object. The axes object with xlabel Time (s) contains 2 objects of type stem. These objects represent Interpolated by 2, Input signal.

Increase the sample rate of an audio signal using a polyphase IIR interpolator and play both the original and interpolated signals.

Note: The audioDeviceWriter System object™ is not supported in MATLAB Online.

Define the allpass branches and create the dsp.IIRInterpolator System object with an interpolation factor of 2.

branches = {dsp.AllpassFilter(AllpassCoefficients=0.1550), ...
    dsp.AllpassFilter(AllpassCoefficients=[0.3726 0.6536])};
iirInterp = dsp.IIRInterpolator(Branches=branches);
L = iirInterp.InterpolationFactor;

Create a dsp.AudioFileReader object to read the audio signal.

afr = dsp.AudioFileReader("speech_dft_8kHz.wav");
fs = afr.SampleRate;

Create an audioDeviceWriter object to play the original audio signal at the original sample rate. Play the audio.

adw = audioDeviceWriter(fs);
while ~isDone(afr)
    audioIn = afr();
    adw(audioIn);
end
release(afr);
pause(0.5);
release(adw);

Create an audioDeviceWriter object to play the interpolated audio signal at the increased sample rate. Read, interpolate, and play the audio.

adw = audioDeviceWriter(fs*L);
reset(afr);
while ~isDone(afr)
    audioIn = afr();
    audioOut = iirInterp(audioIn);
    adw(audioOut);
end
release(afr);
pause(0.5);
release(adw);
release(iirInterp);

Create a polyphase IIR interpolator and an FIR interpolator with the same interpolation factor. Compare their computational cost and frequency response.

Create an IIR interpolator with an interpolation factor of 2 using the dsp.IIRInterpolator object.

branches = {dsp.AllpassFilter(AllpassCoefficients=0.1550), ...
    dsp.AllpassFilter(AllpassCoefficients=[0.3726 0.6536])};
iirInterp = dsp.IIRInterpolator(Branches=branches);

Create an FIR interpolator with the same interpolation factor using the dsp.FIRInterpolator object.

firInterp = dsp.FIRInterpolator(2);

Compare the computational cost of both interpolators using the cost function. The IIR interpolator uses fewer multiplications and additions than the FIR interpolator.

costIIR = cost(iirInterp)
costIIR = struct with fields:
                  NumCoefficients: 3
                        NumStates: 6
    MultiplicationsPerInputSample: 3
          AdditionsPerInputSample: 6

costFIR = cost(firInterp)
costFIR = struct with fields:
                  NumCoefficients: 24
                        NumStates: 23
    MultiplicationsPerInputSample: 24
          AdditionsPerInputSample: 23

Compare the frequency responses of both interpolators using filterAnalyzer. The IIR polyphase interpolator has significantly lower computational cost. However, it has a nonlinear phase response, unlike the FIR interpolator which has linear phase.

filterAnalyzer(iirInterp,firInterp,...
    Analysis="magnitude",OverlayAnalysis="phase")

Create an IIR interpolator and interpolate a multichannel sinusoidal signal. Use a timescope object to visualize the original and interpolated signals.

Define two allpass branches and create the dsp.IIRInterpolator System object.

branches = {dsp.AllpassFilter(AllpassCoefficients=0.1550), ...
    dsp.AllpassFilter(AllpassCoefficients=[0.3726 0.6536])};
iirInterp = dsp.IIRInterpolator(Branches=branches);
L = iirInterp.InterpolationFactor;

Generate a 3-channel signal using the dsp.SineWave object. Each channel contains a sinusoid at a different frequency: 50, 100, and 150 Hz.

fs = 1000;
frameSize = 256;
sineGen = dsp.SineWave(Frequency=[50 100 150],SampleRate=fs, ...
    SamplesPerFrame=frameSize);

Compute the output delay introduced by the IIR interpolator and use it to align the interpolated output with the original signal on the time scope.

delay = outputDelay(iirInterp,FsIn=fs,Fc=50);

Create a timescope object with two input ports to display the original and interpolated signals at their respective sample rates. Apply the delay as a time display offset to align the signals.

scope = timescope(NumInputPorts=2, ...
    SampleRate=[fs fs*L], ...
    TimeDisplayOffset=[0 -delay], ...
    TimeSpanSource="property",TimeSpan=0.05, ...
    ShowLegend=true, ...
    ChannelNames=["Original (Ch 1)","Interpolated (Ch 1)"], ...
    Title="Multichannel Interpolation — Channel 1");

Stream the signal through the IIR interpolator and display the first channel on the time scope.

for k = 1:20
    x = sineGen();
    y = iirInterp(x);
    scope(x(:,1),y(:,1));
end

The interpolated output aligns with the original signal after compensating for the group delay. The IIR interpolator processes each column of the input independently, making it suitable for multichannel applications such as stereo audio or sensor array data.

Release the objects.

release(scope)

release(iirInterp)

Algorithms

Conceptually, the IIR interpolation filter contains an upsampler by L followed by a lowpass IIR filter H(z).

Input x[n] at sample rate fs passing through an upsampler followed by a polyphase IIR filter H(z) to produce output y[m] at rate Lfs

The IIR interpolation filter uses a polyphase structure for efficient implementation. Each branch of the polyphase structure contains a cascade of one or more allpass filter sections.

To derive the polyphase structure, start with the transfer function of the IIR filter H(z). For an interpolation factor of L, the transfer function of the IIR filter in polyphase form is

H(z)=∑k=0L−1z−kEk(zL),

where:

  • L is the interpolation factor that determines the number of polyphase branches.

  • z−k represents the delay associated with the k-th polyphase branch.

  • Ek(z) is a cascade of one or more allpass filter sections in the k-th polyphase branch. A single allpass filter section of order N has the following transfer function:

    E(z)=∑j=0NaN−jz−j1+∑j=1Najz−j

Because the numerator coefficients are the denominator coefficients in reverse order, |E(ejw)| = 1 for all frequencies (allpass property).

To express H(z) in polyphase form, replace it with its polyphase representation.

Polyphase representation of H(z) with input x[n] upsampled by L, split through delay elements into L subfilters E0 through EL-1, then summed to produce y[m]

The multirate noble identity for interpolation is:

Noble identity for interpolation showing that upsampling by L then filtering by E(z^L) equals filtering by E(z) then upsampling by L

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

Polyphase structure after applying noble identity, with input x[n] filtered by subfilters E0 through EL-1, each upsampled by L with successive delays, then summed to produce y[m]

You can replace the upsampling operator, delay block, and adder with a commutator switch. The switch starts on the first branch 0 and moves in the counterclockwise direction, receiving one sample from each branch at each step. The interpolator effectively outputs L samples for every one input sample it receives. Hence, the sample rate at the output of the IIR interpolation filter is Lfs.

Commutator switch receiving output from polyphase subfilters E0 through EL-1, producing output y[m] at rate Lfs from input x[n] at rate fs

References

[1] Renfors, Markku, and T. Saramaki, "Recursive N-th Band Digital Filters, Parts I and II," IEEE Trans. CAS, Vol. 34, pp. 24-51, Jan. 1987.

[2] Milic, Ljiljana. Multirate Filtering for Digital Signal Processing: MATLAB Applications. Information Science Reference, 2009.

[3] Harris, Fredric J. Multirate Signal Processing for Communication Systems. Prentice Hall, 2004.

Version History

Introduced in R2026b