| Signal Processing Blockset™ | ![]() |
Filtering / Multirate Filters
dspmlti4
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 block upsamples the input to a higher rate by inserting L-1 zeros between samples.
The block filters the upsampled data with a direct-form FIR filter.
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. See N.J. Fliege, Multirate Digital Signal Processing: Multirate Systems, Filter Banks, Wavelets for more information.
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 Signal Processing Toolbox™ filter design functions (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.
The FIR Interpolation block supports real and complex floating-point and fixed-point inputs except for complex unsigned fixed-point inputs. This block supports triggered subsystems when you select Maintain input frame rate for the Framing parameter.
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.
An Mi-by-N frame-based matrix input is treated as N independent channels, and the block interpolates 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:
Maintain input frame size
The block generates the output at the interpolated rate by using a proportionally shorter frame period at the output port than at the input port. For interpolation by a factor of L, the output frame period is L times shorter than the input frame period (Tfo = Tfi/L), but the input and output frame sizes are equal.
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.

Maintain input frame rate
The block generates the output at the interpolated rate by using a proportionally larger frame size than the input. For interpolation by a factor of L, the output frame size is L times larger than the input frame size (Mo = Mi*L), but the input and output frame rates are equal.
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.

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.
The FIR Interpolation block is multirate for all settings other than those in the previous table. The amount of latency for multirate operation depends on the Simulink tasking mode and the block's sampling mode, as shown in the following table.
| Multirate... | Sample-Based Latency | Frame-Based Latency |
|---|---|---|
Single-tasking | None | None |
Multitasking | L samples | L frames (Mi samples per frame) |
When the block exhibits latency, the default initial condition is zero. Alternatively, you can enter a value in the Output buffer initial conditions text box. This value is divided by the Interpolation factor and output at the output port until the first filtered input sample is available.
In sample-based cases, the scaled initial conditions appear at the start of each channel, followed immediately by the first filtered input sample, L-1 interpolated values, and so on.
In frame-based cases, with the default initial condition, the first MiL 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 MiL+1, followed by L-1 interpolated values, the second filtered input sample, and so on. See the following example for an illustration of this case.
Note For more information on latency and the Simulink tasking modes, see Excess Algorithmic Delay (Tasking Latency) and Models with Multiple Sample Rates in the Real-Time Workshop® User's Guide. |
The following diagram shows the data types used within the FIR Interpolation block for fixed-point signals.

You can set the coefficient, product output, accumulator, and output data types in the block dialog as discussed in Dialog Box. The diagram shows that input data is stored in the input buffer in the same data type and scaling as the input. Filtered data is stored in the output buffer in the output data type and scaling that you set in the block dialog. Any initial conditions are also stored in the output buffer in the output data type and scaling you set in the block dialog.
The output of the multiplier is in the product output data type when at least one of the inputs to the multiplier is real. When both of the inputs to the multiplier are complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication performed, see Multiplication Data Types.
Construct the frame-based model shown below.

Adjust the block parameters as follows:
Configure the Signal From Workspace block to generate a two-channel signal with frame size of 4 and sample period of 0.25. This represents an output frame period of 1 (0.25*4). The first channel should contain the positive ramp signal 1, 2, ..., 100, and the second channel should contain the negative ramp signal -1, -2, ..., -100.
Signal = [(1:100)' (-1:-1:-100)']
Sample time = 0.25
Samples per frame = 4
Configure the FIR Interpolation block to interpolate the two-channel input by increasing the output frame rate by a factor of 2 relative to the input frame rate. Use a third-order filter (m=3) with normalized cutoff frequency, fn0, of 0.25. (Note that fn0 and m satisfy fn0≤1/L and m > L.)
FIR filter coefficients = fir1(3,0.25)
Interpolation factor = 2
Framing = Maintain input frame size
The filter coefficient vector generated by fir1(3,0.25) is
[0.0386 0.4614 0.4614 0.0386]
or, equivalently,
![]()
Configure the Probe blocks by clearing the Probe width, Probe complex signal, and Probe signal dimensions check boxes (if desired).
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, open the Configuration Parameters dialog box. In the Select pane, click Solver. From the Type list, select Fixed-step, and from the Solver list, select discrete (no continuous states). From the Tasking mode for periodic sample times list, select MultiTasking. 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.
dsp_examples_yout =
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0.0386 -0.0386
0.4614 -0.4614
0.5386 -0.5386
0.9614 -0.9614
1.0386 -1.0386
Since we ran this frame-based multirate model in multitasking mode, the first eight (MiL) output rows are zero. The first filtered input matrix row appears in the output as sample 9 (that is, sample MiL+1). Every other row is an interpolated value.
The doc_polyphaseinterp model illustrates the underlying polyphase implementations of the FIR Interpolation block. Run the model and view the results on the scope. The output of the FIR Interpolation block is the same as the output of the Polyphase Interpolation Filter block.
The doc_mrf_nlp model illustrates the use of the FIR Interpolation block in a number of multistage multirate filters.
The FIR Interpolation block can operate in two different modes. Select the mode in the Coefficient source group box. If you select
Dialog parameters, you enter information about the filter such as structure and coefficients in the block mask.
Multirate filter object (MFILT), you specify the filter using a Filter Design Toolbox™ mfilt object.
Different items appear on the FIR Interpolation block dialog depending on whether you select Dialog parameters or Multirate filter object (MFILT) in the Coefficient source group box. See the following sections for details:
The Main pane of the FIR Interpolation block dialog appears as follows when Dialog parameters is selected in the Coefficient source group box.

Specify the FIR filter coefficients, in descending powers of z.
Specify the integer factor, L, by which to increase the sample rate of the input sequence.
For frame-based operation, specify the method by which to implement the interpolation: increase the output frame rate, or increase the output frame size. This parameter cannot be set to Maintain input frame rate for sample-based signals.
When the block exhibits latency, enter a value in the Output buffer initial conditions text box to specify the value to output at the output port until the first filtered input sample is available. The default initial condition value is 0.
Output buffer initial conditions are stored in the output data type and scaling.
This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the filter defined in the block. For more information on FVTool, see the Signal Processing Toolbox documentation.
Note This button is only available when the Filter Design Toolbox product is installed. If you specify a filter in the Multirate filter variable parameter, you must apply the filter by clicking the Apply button before using the View filter response button. |
The Fixed point pane of the FIR Interpolation block dialog appears as follows when Dialog parameters is specified in the Coefficient source group box.

Select the rounding mode for fixed-point operations. The filter coefficients do not obey this parameter; they always round to Nearest.
Select the overflow mode for fixed-point operations. The filter coefficients do not obey this parameter; they are always saturated.
Choose how you specify the word length and fraction length of the filter coefficients:
When you select Same word length as input, the word length of the filter coefficients match that of the input to the block. In this mode, the fraction length of the coefficients is automatically set to the binary-point only scaling that provides you with the best precision possible given the value and word length of the coefficients.
When you select Specify word length, you can enter the word length of the coefficients, in bits. In this mode, the fraction length of the coefficients is automatically set to the binary-point only scaling that provides you with the best precision possible given the value and word length of the coefficients.
When you select Binary point scaling, you can enter the word length and the fraction length of the coefficients, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the coefficients. This block requires power-of-two slope and a bias of zero.
The filter coefficients do not obey the Rounding mode and the Overflow mode parameters; they are always saturated and rounded to Nearest.
Use this parameter to specify how you would like to designate the product output word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block:
When you select Inherit via internal rule, the product output word length and fraction length are calculated automatically. For information about how the product output word and fraction lengths are calculated when an internal rule is used, see Inherit via Internal Rule.
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. This block requires power-of-two slope and a bias of zero.

As depicted above, inputs to the accumulator are cast to the accumulator data type. The output of the adder remains in the accumulator data type as each element of the input is added to it. Use this parameter to specify how you would like to designate this accumulator word and fraction lengths.
You also use this parameter to specify the accumulator word and fraction lengths resulting from a complex-complex multiplication in the block. See Multiplication Data Types for more information:
When you select Inherit via internal rule, the accumulator word length and fraction length are calculated automatically. For information about how the accumulator word and fraction lengths are calculated when an internal rule is used, see Inherit via Internal Rule.
When you select Same as product output, these characteristics match those of the product output.
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. This block requires power-of-two slope and a bias of zero.
Choose how you specify the output word length and fraction length:
When you select Same as accumulator, these characteristics match those of the accumulator.
A special case occurs when Inherit via internal rule is specified for Accumulator, and block inputs and coefficients are complex. In that case, the output word length be one less than the accumulator word length.
When you select Same as product output, these characteristics match those of the product output.
When you select Same as input, these characteristics match those of the input to the block.
When you select Binary point scaling, you can enter the word length and the fraction length of the output, in bits.
When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the output. This block requires power-of-two slope and a bias of zero.
Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling tool in the Fixed-Point Tool.
The Main pane of the FIR Interpolation block dialog appears as follows when Multirate filter object (MFILT) is specified in the Coefficient source group box.

Specify the multirate filter object (mfilt) that you would like the block to implement. You can do this in one of three ways:
You can fully specify the mfilt object in the block mask.
You can enter the variable name of a mfilt object that is defined in any workspace.
You can enter a variable name for a mfilt object that is not yet defined, as shown in the default value.
For more information on creating mfilt objects, see the mfilt function reference page in the Filter Design Toolbox documentation.
For frame-based operation, specify the method by which to implement the interpolation: increase the output frame rate, or increase the output frame size. This parameter cannot be set to Maintain input frame rate for sample-based signals.
This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the mfilt object specified in the Multirate filter variable parameter. For more information on FVTool, see the Signal Processing Toolbox documentation.
Note This button is only available when the Filter Design Toolbox product is installed. If you specify a filter in the Multirate filter variable parameter, you must apply the filter by clicking the Apply button before using the View filter response button. |
The Fixed-point pane of the FIR Interpolation block dialog appears as follows when Multirate filter object (MFILT) is specified in the Coefficient source group box.

The fixed-point settings of the filter object specified on the Main pane are displayed on the Fixed-point pane. You cannot change these settings directly on the block mask. To change the fixed-point settings you must edit the filter object directly.
For more information on multirate filter objects, see the mfilt function reference page in the Filter Design Toolbox documentation.
Fliege, N. J. Multirate Digital Signal Processing: Multirate Systems, Filter Banks, Wavelets. West Sussex, England: John Wiley & Sons, 1994.
| Port | Supported Data Types |
|---|---|
Input |
|
Output |
|
| FIR Decimation | Signal Processing Blockset |
| FIR Rate Conversion | Signal Processing Blockset |
| Upsample | Signal Processing Blockset |
| fir1 | Signal Processing Toolbox |
| fir2 | Signal Processing Toolbox |
| firls | Signal Processing Toolbox |
| interp | Signal Processing Toolbox |
![]() | FIR Decimation | FIR Rate Conversion | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |