Interpolation
Interpolate values of real input samples
Libraries:
DSP System Toolbox /
Signal Operations
Description
The Interpolation block interpolates discrete, real inputs by using linear or FIR interpolation. The block accepts a vector, a matrix, or an ND array. The block outputs a scalar, a vector, a matrix, or an ND array of the interpolated values.
You must specify the interpolation points, the times at which to interpolate values in a onebased interpolation array I_{Pts}. An entry of 1 in I_{Pts} refers to the first sample of the input data, an entry of 2.5 refers to the sample halfway between the second and third input sample, and so on. Depending on the dimensions of the input data, I_{Pts} can be a scalar, a lengthP row, or a column vector, a PbyN matrix, or an ND array where P is the size of the first dimension of the ND array. In most cases, P can be any positive integer. For more information about valid interpolation arrays, refer to the tables in Pts and Interpolation points.
In most cases, the block applies I_{Pts} across
the first dimension of an ND input array or to each input vector.
You can set the block to apply the same interpolation array for all input data, static
interpolation points entered on the block mask, or to use a different interpolation
array for each ND array, matrix, or vector input, timevarying
interpolation points received through the Pts
input
port.
Ports
Input
In — Input signal
scalar  vector  matrix  ND array
Input signal, specified as a scalar, vector, matrix, or ND array.
This port is unnamed until Source
of interpolation points
is set to Input
port
.
Data Types: single
 double
Pts — Interpolation points
scalar  vector  matrix  ND array
Interpolation points, specified as a scalar, vector, matrix, or ND array.
For more details on the block's behavior when the Source
of interpolation points
parameter is set to
Input port
, see How the Block Applies Interpolation Arrays to Inputs.
Dependencies
This port is unavailable until Source of interpolation points
is set to
Input port
.
Data Types: single
 double
Output
Out — Output signal
scalar  vector  matrix  ND array
Output signal, specified as a vector, matrix, or ND array.
This port is unnamed until Source
of interpolation points
is set to Input
port
.
Data Types: single
 double
Parameters
Source of interpolation points — Interpolation point input method
Specify via dialog
(default)  Input port
Choose how you want to specify the interpolation points:
Specify via dialog
–– TheInterpolation points
parameter becomes available. Use this option for static interpolation points.Input port
–– ThePts
port appears on the block. The block uses the input to this port as the interpolation points. Use this option for timevarying interpolation points.
For more information, see Specifying Static Interpolation Points and Specifying TimeVarying Interpolation Points.
Interpolation points — Interpolation points
[1.1 4.8 2.67 1.6 3.2]'
(default)  scalar  vector  matrix  ND array
The array of points in time at which to interpolate the input signal (I_{Pts}). An entry of 1 in I_{Pts} refers to the first sample of the input, an entry of 2.5 refers to the sample halfway between the second and third input sample, and so on. See How the Block Applies Interpolation Arrays to Inputs.
Tunable: Yes
Dependencies
This parameter becomes available only when the Source
of interpolation points
is set to Specify
via dialog
. For more information, see Specifying Static Interpolation Points.
Interpolation mode — Interpolation mode
Linear
(default)  FIR
Sets the block to interpolate by either Linear
or FIR
interpolation. For more information, see
Linear Interpolation Mode and
FIR Interpolation Mode.
Interpolation filter halflength — Half length of FIR interpolation filter
3
(default)  positive integer
Specify the halflength of the FIR interpolation filter
(P
). To perform the interpolation in
FIR
mode, the block uses the nearest
2×P
lowrate samples. In most cases,
P
lowrate samples must appear below and above each
interpolation point. If you interpolate at a lowrate sample point, the
block includes that lowrate sample in the required 2*P
samples and requires only 2*P
–1 neighboring lowrate
samples. If an interpolation point does not have the required number of
neighboring lowrate samples, the block interpolates that point using linear
interpolation.
Dependencies
This parameter becomes available only when the Interpolation mode
is set to
FIR
. For more information, see FIR Interpolation Mode.
Interpolation points per input sample — Interpolation points per sample
3
(default)
Number of points per input sample, upsampling
factor (L
), at which the block computes a
unique FIR interpolation filter. To perform the FIR interpolation, the block
uses a polyphase structure that has L
filter arms of
length 2*P
.
For example, if L
=4
, the block
constructs a polyphase filter with four arms. The block then interpolates at
points corresponding to 1 +i/L
, 2
+i/L
, 3
+i/L
..., where the integers 1, 2, and 3 represent the lowrate
samples, and i=0,1,2,3
. To interpolate
at a point that does not directly correspond to an arm of the polyphase
filter requires an extra computation. The block first rounds that point down
to the nearest value that does correspond to an arm of the polyphase filter.
To interpolate at the point 2.2, the block rounds 2.2 down to 2, and
computes the FIR interpolation by using the first arm of the polyphase
filter structure. Similarly, to interpolate the point 2.65, the block rounds
the value down to 2.5 and uses the third arm of the polyphase filter
structure.
Dependencies
This parameter becomes available only when the Interpolation mode
is set to
FIR
. For more information, see FIR Interpolation Mode.
Normalized input bandwidth — Normalized input bandwidth
0.5
(default)  scalar in (0 1]
The bandwidth of the input divided by Fs/2 (half the input sample frequency), specified as a scalar in the range (0 1].
Dependencies
This parameter becomes available only when the Interpolation mode
is set to
FIR
. For more information, see FIR Interpolation Mode.
Out of range interpolation points — Error handling for outofrange points
Clip
(default)  Clip and warn
 Error
Valid values in the interpolation array
I_{Pts} range from 1 to the
number of samples in each channel of the input. For instance, given a
length5 input vector D
, all entries of
I_{Pts} must range from 1 to 5.
I_{Pts} cannot contain entries
such as 7 or 9 because there is no 7th or 9th entry in
D
.
The Out of range interpolation points parameter sets how the block handles interpolation points that are fall outside the valid range. The parameter has these settings:
Clip
— The block replaces any outofrange values in I_{Pts} with the closest value in the valid range (from 1 to the number of input samples), and then proceeds with computations by using the clipped version of I_{Pts}.Clip and warn
— In addition toClip
, the block issues a warning at the MATLAB^{®} command line every time clipping occurs.Error
— When the block encounters an outofrange value in I_{Pts}, the simulation stops, and the block issues an error at the MATLAB command line.
As an example of clipping, suppose the block is set to clip outofrange interpolation points and gets these input vector and interpolation points:
D = [11 22 33 44]'
I_{Pts} = [10 2.6 3]'
Because D has four samples, valid interpolation points
range from 1 to 4. The block clips the interpolation point 10 to 4 and the
point 3 to 1, resulting in the clipped interpolation vector
I_{PtsClipped} = [4 2.6
1]'
.
Block Characteristics
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

More About
Specifying Static Interpolation Points
To supply the block with a static interpolation array, that is an interpolation array applied to every vector or ND array of input data), perform the following steps:
Set the
Source of interpolation points
parameter toSpecify via dialog
.Enter the interpolation array in the
Interpolation points
parameter. To learn about interpolation arrays, see How the Block Applies Interpolation Arrays to Inputs.
Specifying TimeVarying Interpolation Points
To supply the block with timevarying interpolation arrays, where the block uses a different interpolation array for each vector or ND array input, perform the following steps:
Set the
Source of interpolation points
parameter toInput port
. ThePts
port appears on the block.Generate a signal of interpolation arrays and supply it to the Pts port. The block uses the input to this port as the interpolation points. To learn about interpolation arrays, see How the Block Applies Interpolation Arrays to Inputs.
How the Block Applies Interpolation Arrays to Inputs
The interpolation array I_{Pts} represents the points in time at which to interpolate values of the input signal. An entry of 1 in I_{Pts} refers to the first sample of the input, an entry of 2.5 refers to the sample halfway between the second and third input sample, and so on. In most cases, when I_{Pts} is a vector, it can be of any length.
Valid values in the interpolation array,
I_{Pts}, range from 1 to the number of
samples in each channel of the input. To learn how the block handles outofrange
interpolation values, see Out of range
interpolation points
.
Depending on the dimension of the input and the dimension of I_{Pts}, the block usually applies I_{Pts} to the input in one of the following ways:
Applies the I_{Pts} array across the first dimension of an ND array, resulting in an ND array output.
Applies the vector I_{Pts} to each input vector (as if the input vector were a single channel), resulting in a vector output with the same orientation as the input (row or column).
These tables summarize how the block applies the interpolation array I_{Pts} to all the possible types of inputs and shows the resulting output dimensions.
The first table describes the block's behavior when the Source of
interpolation points
is Specify via
dialog
.
Specify Interpolation Points Through Dialog Box
Input Dimensions  Valid Dimensions of Interpolation Array I _{Pts}  How Block Applies I _{Pts} to Input  Output Dimensions (FrameBased) 

MbyNbyK matrix  Pby1 column  Applies I_{Pts} to the first dimension of the input  PbyNbyK array 
PbyNbyK matrix  Applies each column of I_{Pts} (each element of I_{Pts}) to the corresponding column of the input matrix  PbyNbyK array  
MbyN matrix  1byN row  Applies each column of I_{Pts} (each element of I_{Pts}) to the corresponding column of the input matrix  1byN row 
Pby1 column  Applies I_{Pts} to each input column  PbyN matrix  
PbyN matrix  Applies the columns of I_{Pts} to the corresponding columns of the input matrix  
Mby1 column  Pby1 column  Applies I_{Pts} to the input column  Pby1 column 
1byN row (not recommended)  1byN row  Not Applicable. Block copies input vector  1byN row, a copy of the input vector 
Pby1 column  PbyN matrix where each row is a copy of the input vector  
PbyN matrix 
The next table describes the block's behavior when the Source of
interpolation points is Input port
.
Specify Interpolation Points Through Input Port
Input Dimensions  Valid Dimensions of Interpolation Array I _{Pts}  How Block Applies I _{Pts} to Input  Output Dimensions (FrameBased) 

MbyNbyK matrix  Unoriented vector or column vector of length P  Applies I_{Pts} to the first dimension of the input  PbyNbyK array 
PbyNbyK matrix  Applies each column of I_{Pts} (each element of I_{Pts}) to the corresponding column of the input matrix  PbyNbyK array  
MbyN matrix  1byN row  Applies each column of I_{Pts} (each element of I_{Pts}) to the corresponding column of the input matrix  1byN row 
Pby1 column  Applies I_{Pts} to each input column  PbyN matrix  
PbyN matrix  Applies the columns of I_{Pts} to the corresponding columns of the input matrix  
Mby1 column  Pby1 column  Applies I_{Pts} to the input column  Pby1 column 
1byN row (not recommended)  1byN row  Not Applicable. Block copies input vector  1byN row, a copy of the input vector 
Pby1 column  PbyN matrix where each row is a copy of the input vector  
PbyN matrix 
Algorithms
Linear Interpolation Mode
When Interpolation
mode
is set to Linear
, the block interpolates data
values by assuming that the data varies linearly between samples taken at adjacent
sample times.
For instance, if the input signal D = [1 2 1.5 3 0.25]', the plot on the left shows the samples in D and the plot on the right shows the linearly interpolated values between the samples in D.
The following figure illustrates the case of a block in linear interpolation mode that is set to clip outofrange interpolation points. The vector D supplies the input data and the vector I_{Pts} supplies the interpolation points:
D = [1 2 1.5 3 0.25]'
I_{Pts} = [4 2.7 4.3 10]'
The block clips the invalid interpolation points and outputs the linearly
interpolated values in a vector, [1 1.65 2.175 0.25]'
.
FIR Interpolation Mode
When Interpolation
mode
is set to FIR
, the block interpolates
data values by using an FIR interpolation filter, specified by various block
parameters. For more information, see FIR Interpolation Mode in the
Variable Fractional Delay block reference.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)