DSP Blockset | ![]() ![]() |
Upsample and filter an input signal.
Library
Filtering / Multirate Filters
Description
The FIR Interpolation block resamples the discrete-time input at a rate L times faster than the input sample rate, where the integer L is specified by the Interpolation factor parameter. This process consists of two steps:
The FIR Interpolation block implements the above upsampling and FIR filtering steps together using a polyphase filter structure, which is more efficient than straightforward upsample-then-filter algorithms.
The FIR filter coefficients parameter specifies the numerator coefficients of the FIR filter transfer function H(z).
The coefficient vector, [b(1) b(2) ... b(m)]
, can be generated by one of the filter design functions in the Signal Processing Toolbox (such as fir1
), and should have a length greater than the interpolation factor (m>L). The filter should be lowpass with normalized cutoff frequency no greater than 1/L. All filter states are internally initialized to zero.
Sample-Based Operation
An M-by-N sample-based matrix input is treated as M*N independent channels, and the block interpolates each channel over time. The output sample period is L times shorter than the input sample period (Tso = Tsi/L), and the input and output sizes are identical.
Frame-Based Operation
An Mi-by-N frame-based matrix input is treated as N independent channels, and the block decimates each channel over time. The Framing parameter determines how the block adjusts the rate at the output to accommodate the added samples. There are two available options:
The example below shows a single-channel input with a frame period of 1 second (Sample time = 1/64
and Samples per frame = 64
in the Signal From Workspace block) being interpolated by a factor of 4 to a frame period of 0.25 second. The input and output frame sizes are identical.
The example below shows a single-channel input of frame size 16 being interpolated by a factor of 4 to a frame size of 64. The block's input and output frame rates are identical.
Latency
Zero Latency. The FIR Interpolation block has zero tasking latency for all single-rate operations. The block is single-rate for the particular combinations of sampling mode and parameter settings shown in the table below.
Sampling Mode |
Parameter Settings |
Sample-based |
Interpolation factor parameter, L, is 1 . |
Frame-based |
Interpolation factor parameter, L, is 1 , or Framing parameter is Maintain input frame rate. |
Note that in sample-based mode, single-rate operation occurs only in the trivial case of factor-of-1 interpolation.
The block also has zero latency for sample-based multirate operations in the Simulink single-tasking mode. Zero tasking latency means that the block propagates the first filtered input (received at t=0) as the first input sample, followed by L-1 interpolated values, the second filtered input sample, and so on.
Nonzero Latency. The FIR Interpolation block is multirate for all settings other than those in the above table. The amount of latency for multirate operation depends on the Simulink tasking mode and the block's sampling mode, as shown in the table below.
Multirate... |
Sample-Based Latency |
Frame-Based Latency |
Single-tasking |
None |
One frame (Mi samples) |
Multitasking |
One sample |
One frame (Mi samples) |
In cases of one-sample latency, a zero initial condition appears as the first output sample in each channel, followed immediately by the first filtered input sample, L-1 interpolated values, and so on.
In cases of one-frame latency, the first Mi output rows contain zeros, where Mi is the input frame size. The first filtered input sample (first filtered row of the input matrix) appears in the output as sample Mi+1, followed by L-1 interpolated values, the second filtered input sample, and so on. See the example below for an illustration of this case.
See Excess Algorithmic Delay (Tasking Latency) and "The Simulation Parameters Dialog Box" in the Simulink documentation for more information about block rates and the Simulink tasking modes.
Example 1
Construct the frame-based model shown below.
Adjust the block parameters as follows.
This model is multirate because there are at least two distinct sample rates, as shown by the two Probe blocks. To run this model in the Simulink multitasking mode, select Fixed-step and discrete from the Type controls in the Solver panel of the Simulation Parameters dialog box, and select MultiTasking from the Mode parameter. Also set the Stop time to 30
.
Run the model and look at the output, yout
. The first few samples of each channel are shown below.
Since we ran this frame-based multirate model in multitasking mode, the first four (Mi) output rows are zero. The first filtered input matrix row appears in the output as sample 5 (i.e., sample Mi+1). Every second row is an interpolated value.
Example 2
The dspintrp
demo provides another simple example, and the dspmrf_menu
demo illustrates the use of the FIR Interpolation block in a number of multistage multirate filters.
Dialog Box
Supported Data Types
To learn how to convert to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.
See Also
FIR Decimation |
DSP Blockset |
FIR Rate Conversion |
DSP Blockset |
Upsample |
DSP Blockset |
fir1 |
Signal Processing Toolbox |
fir2 |
Signal Processing Toolbox |
firls |
Signal Processing Toolbox |
interp |
Signal Processing Toolbox |
remez |
Signal Processing Toolbox |
See the following sections for related information:
![]() | FIR Decimation | FIR Rate Conversion | ![]() |