# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

# Interpolation

Interpolate values of real input samples

## Library

Signal Operations

`dspsigops`

## Description

The Interpolation block interpolates discrete, real, inputs using linear or FIR interpolation. The block accepts vector, matrix, or an N-D array. The block outputs a scalar, vector, matrix, or N-D array of the interpolated values.

You must specify the interpolation points (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 half-way 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 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 How the Block Applies Interpolation Arrays to Inputs.

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 via the Pts input port).

### Specifying Static Interpolation Points

To supply the block with a static interpolation array (an interpolation array applied to every vector or N-D array of input data), perform the following steps:

### 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:

1. Set the Source of interpolation points parameter to `Input port`, the Pts port appears on the block.

2. 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 half-way 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 Handling 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).

The following tables summarize how the block applies the interpolation array IPts to all the possible types of inputs, and show the resulting output dimensions.

The first table describes the block's behavior when the Source of interpolation points is `Specify via dialog` .

Input DimensionsValid Dimensions of Interpolation Array IPtsHow Block Applies IPts to InputOutput 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

1-by-P row

(the algorithm treats IPts as a column)

Applies IPts to the input column

P-by-1 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`.

Input DimensionsValid Dimensions of Interpolation Array IPtsHow Block Applies IPts to InputOutput 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

1-by-P row

Applies IPts to the input column

P-by-1 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

### Handling Out-of-Range Interpolation Points

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, since 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, and has the following 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 using the clipped version of IPts.

• `Clip and warn` — In addition to `Clip`, 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.

### Example of Clipping

Suppose the block is set to clip out-of-range interpolation points, and gets the following 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]'`.

### 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 following 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 using an FIR interpolation filter, specified by various block parameters. See FIR Interpolation Mode in the Variable Fractional Delay block reference for more information.

## Parameters

Source of interpolation points

Choose how you want to specify the interpolation points. If you select `Specify via dialog`, the Interpolation points parameter become available. Use this option for static interpolation points. If you select `Input port`, the Pts 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

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 half-way between the second and third input sample, and so on. See How the Block Applies Interpolation Arrays to Inputs. Tunable (Simulink).

Interpolation mode

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

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. However, 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.

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

Also known as the upsampling factor, this parameter defines the number of points per input sample (`L`) at which the block computes a unique FIR interpolation filter. To perform the FIR Interpolation, the block uses a polyphase structure with `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. Thus, to interpolate at the point 2.2, the block rounds 2.2 down to 2, and computes the FIR interpolation 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.

This parameter becomes available only when the Interpolation mode is set to `FIR`. For more information, see FIR Interpolation Mode.

Normalized input bandwidth

The bandwidth of the input divided by Fs/2 (half the input sample frequency).

This parameter is only available when the Interpolation mode is set to `FIR`. For more information, see FIR Interpolation Mode.

Out of range interpolation points

When an interpolation point is out of range, this parameter sets the block to either clip the interpolation point, clip the value and issue a warning at the MATLAB command line, or stop the simulation and issue an error at the MATLAB command line. For more information, see Handling Out-of-Range Interpolation Points.

## Supported Data Types

PortSupported Data Types

In

• Double-precision floating point

• Single-precision floating point

Pts

• Double-precision floating point

• Single-precision floating point

Out

• Double-precision floating point

• Single-precision floating point

#### Introduced before R2006a

Was this topic helpful?

Watch now