Package: dsp
Linear or FIR interpolation
The Interpolator
object interpolates realvalued
inputs using linear or polyphase FIR interpolation.
To interpolate realvalued inputs:
Define and set up your interpolation object. See Construction.
Call step
to interpolate the input
according to the properties of dsp.Interpolator
.
The behavior of step
is specific to each object in
the toolbox.
H = dsp.Interpolator
returns
a handle to an interpolation object, H
. The interpolation
method defaults to Linear
and the interpolation
points default to a 5×1 vector.
H = dsp.Interpolator('
returns
an interpolation object, PropertyName
',PropertyValue
,...)H
, with the specified property
name and value pairs.

Source of interpolation points You can select a value of 

Interpolation points This property only applies when you set the The valid range of the values in the interpolation vector is
from 

Interpolation method Specify the interpolation method as 

Interpolation filter half length This property applies only when you set the
For example, for an input The longer the 

Interpolation points per input sample This property only applies when you set the If you specify interpolation points which do not correspond
to a polyphase subfilter, the object rounds the point down to the
nearest interpolation point associated with a polyphase subfilter.
For example, you set the 

Normalized input bandwidth This property applies only when you set the 
clone  Create interpolator object with same property values 
getNumInputs  Number of expected inputs to step method 
getNumOutputs  Number of outputs of step method 
isLocked  Locked status for input attributes and nontunable properties 
release  Allow property value and input characteristics changes 
step  Linear or FIR interpolation 
A polyphase implementation of an FIR interpolation filter splits the lowpass FIR filter impulse response into a number of different subfilters. Let L represent the number of interpolation points per sample, or the upsampling factor, and P the half length of the polyphase subfilters. Indexing from zero, if h(n) is the impulse response of the FIR filter, the kth subfilter is:
$$\begin{array}{l}{h}_{k}(n)=h(k+nL)\text{\hspace{1em}}k=0,1,\dots ,L1\text{\hspace{1em}}n=0,1,\dots ,2P1\\ \\ \end{array}$$
The following table describes the decomposition of an 18coefficient FIR filter into 3 polyphase subfilters of length 6, the defaults for the FIR interpolator object:
Coefficients  Polyphase Subfilter 

h(0),h(3),h(6), ..., h(15)  h_{0}(n) 
h(1),h(4),h(7), ..., h(16)  h_{1}(n) 
h(2),h(5),h(8), ..., h(17)  h_{2}(n) 
The following code shows how to find the polyphase subfilters for the default FIR interpolator object:
H = dsp.Interpolator('Method','FIR'); L = H.InterpolationPointsPerSample; P = H.FilterHalfLength; FiltCoeffs = intfilt(L,P,H.Bandwidth); % Returns filter of length 2*P*L1 FiltLen=length(FiltCoeffs); FiltCols = ceil(FiltLen/2/L); % We need 2*P*L coefficients % Prepending a zero does not affect the filter magnitude FiltCoeffs = [zeros(FiltCols*2*LFiltLen,1); FiltCoeffs(:)]; % Each column of PolyPhaseCoeffs is a polyphase subfilter PolyPhaseCoeffs = reshape(FiltCoeffs,FiltCols,2*L)';
Compare linear interpolation with FIR interpolation:
x =[1 4]; x = repmat(x,1,4); x1 = 1:0.25:8; hFIR =dsp.Interpolator('Method','FIR','FilterHalfLength',2,... 'InterpolationPoints',x1','InterpolationPointsPerSample',4); hLin =dsp.Interpolator('InterpolationPoints',x1'); OutFIR = step(hFIR,x'); OutLin = step(hLin,x'); stem(OutFIR,'b.','linewidth',2); hold on; stem(OutLin,'r','markerfacecolor',[1 0 0]); axis([0 30 0 5]); legend('FIR','Linear','Location','Northeast');
For the indices 1 to 5 and 25 to 29, the interpolator object uses linear interpolation in both cases. The reason for this is that there are not enough lowrate samples surrounding the interpolation points at those indices to use FIR interpolation with the specified filter length.
Interpolate a sinusoid with linear interpolation:
t = 0:.0001:.0511; x = sin(2*pi*20*t); x1 = x(1:50:end); I = 1:0.1:length(x1); H = dsp.Interpolator('InterpolationPointsSource',... 'Input port'); y = H.step(x1',I'); stem(I',y, 'r'); title('Original and Interpolated Signal'); hold on; stem(x1, 'Linewidth', 2); legend('Interpolated','Original');
Interpolate a sum of sinusoids with FIR interpolation and Input
Port
as the source of interpolation points:
Fs = 1000; t = 0:(1/Fs):0.1(1/Fs); x = cos(2*pi*50*t)+0.5*sin(2*pi*100*t); x1 = x(1:4:end); I = 1:(1/4):length(x1); % Decimate without aliasing H = dsp.Interpolator('Method','FIR',... 'FilterHalfLength',3,'InterpolationPointsSource','Input Port'); y = H.step(x1',I'); stem(I,y,'r'); hold on; axis([0 25 2 2]); stem(x1,'b','linewidth',2); legend('Interpolated Signal','Original',... 'Location','Northeast');
This object implements the algorithm, inputs, and outputs described on the Interpolation block reference page. The object properties correspond to the Simulink^{®} block parameters, except:
Out of range interpolation points —
The interpolator object only has the Clip option.
The Simulink block has the additional Clip and warn and Error options. 