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 N-D array. The block outputs a scalar, a vector, a matrix, or an N-D array of the interpolated values.
You must specify the interpolation points, the times at which to interpolate values in a one-based interpolation array IPts. An entry of 1 in IPts 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, IPts can be a scalar, a length-P row, or a column vector, a P-by-N matrix, or an N-D array where P is the size of the first dimension of the N-D 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 IPts across
the first dimension of an N-D 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 N-D array, matrix, or vector input, time-varying
interpolation points received through the Pts
input
port.
Ports
Input
In — Input signal
scalar | vector | matrix | N-D array
Input signal, specified as a scalar, vector, matrix, or N-D 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 | N-D array
Interpolation points, specified as a scalar, vector, matrix, or N-D 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 | N-D array
Output signal, specified as a vector, matrix, or N-D 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 time-varying interpolation points.
For more information, see Specifying Static Interpolation Points and Specifying Time-Varying Interpolation Points.
Interpolation points — Interpolation points
[1.1 4.8 2.67 1.6 3.2]'
(default) | scalar | vector | matrix | N-D array
The array of points in time at which to interpolate the input signal (IPts). An entry of 1 in IPts 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 half-length — Half length of FIR interpolation filter
3
(default) | positive integer
Specify the half-length of the FIR interpolation filter
(P
). To perform the interpolation in
FIR
mode, the block uses the nearest
2×P
low-rate samples. In most cases,
P
low-rate samples must appear below and above each
interpolation point. If you interpolate at a low-rate sample point, the
block includes that low-rate sample in the required 2*P
samples and requires only 2*P
–1 neighboring low-rate
samples. If an interpolation point does not have the required number of
neighboring low-rate 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 low-rate
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 out-of-range points
Clip
(default) | Clip and warn
| Error
Valid values in the interpolation array
IPts range from 1 to the
number of samples in each channel of the input. For instance, given a
length-5 input vector D
, all entries of
IPts must range from 1 to 5.
IPts 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 out-of-range values in IPts 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 IPts.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 out-of-range value in IPts, 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 out-of-range interpolation points and gets these input vector and interpolation points:
D = [11 22 33 44]'
IPts = [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
IPtsClipped = [4 2.6
1]'
.
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing 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 N-D 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 Time-Varying Interpolation Points
To supply the block with time-varying interpolation arrays, where the block uses a different interpolation array for each vector or N-D 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 IPts represents the points in time at which to interpolate values of the input signal. An entry of 1 in IPts 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 IPts is a vector, it can be of any length.
Valid values in the interpolation array,
IPts, range from 1 to the number of
samples in each channel of the input. To learn how the block handles out-of-range
interpolation values, see Out of range
interpolation points
.
Depending on the dimension of the input and the dimension of IPts, the block usually applies IPts to the input in one of the following ways:
Applies the IPts array across the first dimension of an N-D array, resulting in an N-D array output.
Applies the vector IPts 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 IPts 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 (Frame-Based) |
---|---|---|---|
M-by-N-by-K matrix | P-by-1 column | Applies IPts to the first dimension of the input | P-by-N-by-K array |
P-by-N-by-K matrix | Applies each column of IPts (each element of IPts) to the corresponding column of the input matrix | P-by-N-by-K array | |
M-by-N matrix | 1-by-N row | Applies each column of IPts (each element of IPts) to the corresponding column of the input matrix | 1-by-N row |
P-by-1 column | Applies IPts to each input column | P-by-N matrix | |
P-by-N matrix | Applies the columns of IPts to the corresponding columns of the input matrix | ||
M-by-1 column | P-by-1 column | Applies IPts to the input column | P-by-1 column |
1-by-N row (not recommended) | 1-by-N row | Not Applicable. Block copies input vector | 1-by-N row, a copy of the input vector |
P-by-1 column | P-by-N matrix where each row is a copy of the input vector | ||
P-by-N 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 (Frame-Based) |
---|---|---|---|
M-by-N-by-K matrix | Unoriented vector or column vector of length P | Applies IPts to the first dimension of the input | P-by-N-by-K array |
P-by-N-by-K matrix | Applies each column of IPts (each element of IPts) to the corresponding column of the input matrix | P-by-N-by-K array | |
M-by-N matrix | 1-by-N row | Applies each column of IPts (each element of IPts) to the corresponding column of the input matrix | 1-by-N row |
P-by-1 column | Applies IPts to each input column | P-by-N matrix | |
P-by-N matrix | Applies the columns of IPts to the corresponding columns of the input matrix | ||
M-by-1 column | P-by-1 column | Applies IPts to the input column | P-by-1 column |
1-by-N row (not recommended) | 1-by-N row | Not Applicable. Block copies input vector | 1-by-N row, a copy of the input vector |
P-by-1 column | P-by-N matrix where each row is a copy of the input vector | ||
P-by-N 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 out-of-range interpolation points. The vector D supplies the input data and the vector IPts supplies the interpolation points:
D = [1 2 1.5 3 0.25]'
IPts = [-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)