Documentation |
Interpolate values of real input samples
The Interpolation block interpolates discrete, real, inputs using linear or FIR interpolation. The block accepts both sample- and frame-based input data in the form of a vector, matrix, or sample-based N-D array. The block outputs a scalar, vector, matrix, or N-D array of the interpolated values, which has the same frame status as the input data.
You must specify the interpolation points (times at which to interpolate values) in a one-based 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 half-way 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 length-P row or column vector, a P-by-N frame-based matrix, or a sample-based 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 I_{Pts} 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).
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:
Set the Source of interpolation points parameter to Specify 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.
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 to Input port, the Pts 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.
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 half-way 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 out of range interpolation values, see Handling Out-of-Range Interpolation Points.
Depending on the dimension and frame status 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 a sample-based N-D array or frame-based matrix input, resulting in a sample-based N-D array or frame-based matrix 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).
The following tables summarize how the block applies the interpolation array I_{Pts} to all the possible types of sample- and frame-based 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 and the input is sample based.
Input Dimensions (Sample Based) | Valid Dimensions of Interpolation Array I_{Pts} | How Block Applies I_{Pts} to Input | Output Dimensions (Sample Based) |
---|---|---|---|
N-D Array (ex. M-by-N-by-Q) | 1-by-P row | Applies I_{Pts} to the first dimension of the input array | P-by-N-by-Q array |
P-by-1 column | |||
P-by-N-by-Q array | Applies the columns of I_{Pts} to the corresponding columns of the input array | ||
M-by-1 column | 1-by-P row (block treats I_{n} as a column) | Applies I_{Pts} to the input column | P-by-1 column |
P-by-1 column | |||
1-by-N row | 1-by-P row | Applies I_{n} to the input row | 1-by-P row |
P-by-1 column (block treats I_{Pts} as a row) |
The next table describes the block's behavior when the Source of interpolation points is Specify via dialog and the input is frame based.
Input Dimensions (Frame Based) | Valid Dimensions of Interpolation Array I_{Pts} | How Block Applies I_{Pts} to Input | Output Dimensions (Frame Based) |
---|---|---|---|
M-by-N matrix | 1-by-N row | Applies each column of I_{Pts} (each element of I_{Pts}) to the corresponding column of the input matrix | 1-by-N row |
P-by-1 column | Applies I_{Pts} to each input column | P-by-N matrix | |
P-by-N matrix | Applies the columns of I_{Pts} to the corresponding columns of the input matrix | ||
M-by-1 column | 1-by-P row (block treats I_{Pts} as a column) | Applies I_{Pts} 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 and the input is sample based.
Input Dimensions (Sample Based) | Valid Dimensions of Interpolation Array I_{Pts} | How Block Applies I_{Pts} to Input | Output Dimensions (Sample Based) |
---|---|---|---|
N-D Array (ex. M-by-N-by-Q) | Sample-based 1-by-P row | Applies I_{Pts} to the first dimension of the input array | P-by-N-by-Q array |
Sample- or frame-based P-by-1 column | |||
Sample-based P-by-N-by-Q array | Applies the columns of I_{Pts} to the corresponding columns of the input array | ||
M-by-1 column | Sample-based 1-by-P row | Applies I_{Pts} to the input column | P-by-1 column |
Sample- or frame-based P-by-1 column | |||
1-by-N row | Sample-based 1-by-P row | Applies I_{Pts} to the input row | 1-by-P row |
Sample or frame-based P-by-1 column |
The next table describes the block's behavior when the Source of interpolation points is Input port and the input is frame based.
Input Dimensions (Frame Based) | Valid Dimensions of Interpolation Array I_{Pts} | How Block Applies I_{Pts} to Input | Output Dimensions (Frame Based) |
---|---|---|---|
M-by-N matrix | Frame-based 1-by-N row | Applies each column of I_{Pts} (each element of I_{Pts}) to the corresponding column of the input matrix | 1-by-N row |
Sample-based 1-by-P row | Applies I_{Pts} to each input column | P-by-N matrix | |
Frame- or sample-based P-by-1 column | |||
Frame- or sample-based P-by-N matrix | Applies the columns of I_{Pts} to the corresponding columns of the input matrix | ||
M-by-1 column | Sample-based 1-by-P row | Applies I_{Pts} to the input column | P-by-1 column |
Frame- or sample-based P-by-1 column | |||
1-by-N row (not recommended) | Frame-based 1-by-N row | Not Applicable. Block copies input vector | 1-by-N row, a copy of the input vector |
Sample-based 1-by-P row | P-by-N matrix where each row is a copy of the input vector | ||
Frame- or sample-based P-by-1 column | |||
Frame- or sample-based P-by-N matrix |
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 length-5 input vector D, all entries of I_{Pts} must range from 1 to 5. I_{Pts} 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 I_{Pts} 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 I_{Pts}.
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 I_{Pts}, the simulation stops, and the block issues an error at the MATLAB command line.
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]'
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]'.
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 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]'.
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.
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.
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 half-way between the second and third input sample, and so on. See How the Block Applies Interpolation Arrays to Inputs. Tunable.
Sets the block to interpolate by either linear or FIR interpolation. For more information, see Linear Interpolation Mode and FIR Interpolation Mode.
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.
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.
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.
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.