| Signal Processing Blockset™ | ![]() |
Filtering / Multirate Filters
dspmlti4
The FIR Rate Conversion block resamples the discrete-time input to a period K/L times the input sample period, where the integer K is specified by the Decimation factor parameter and the integer L is specified by the Interpolation factor parameter. The resampling process consists of the following steps:
The block upsamples the input to a higher rate by inserting L-1 zeros between input samples.
The upsampled data is passed through a direct-form II transpose FIR filter.
The block downsamples the filtered data to a lower rate by discarding K-1 consecutive samples following each sample retained.
K and L must be relatively prime integers; that is, the ratio K/L cannot be reducible to a ratio of smaller integers. The FIR Rate Conversion block implements the above three steps together using a polyphase filter structure, which is more efficient than straightforward upsample-filter-decimate algorithms. See Orfanidis [1] 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 min(1/L,1/K). All filter states are internally initialized to zero.
The FIR Rate Conversion block supports real and complex floating-point and fixed-point inputs except for complex unsigned fixed-point inputs.
This block accepts only frame-based inputs. An Mi-by-N frame-based matrix input is treated as N independent channels, and the block resamples each channel independently over time.
The Interpolation factor, L, and Decimation factor, K, must satisfy the relation
![]()
for an integer output frame size Mo. The simplest way to satisfy this requirement is to let the Decimation factor equal the input frame size, Mi. The output frame size, Mo, is then equal to the Interpolation factor. This change in the frame size, from Mi to Mo, produces the desired rate conversion while leaving the output frame period the same as the input (Tfo = Tfi).

The FIR Rate Conversion block has no tasking latency. The block propagates the first filtered input (received at t=0) as the first output sample.
The following diagram shows the data types used within the FIR Rate Conversion 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.
The doc_audio_src model provides a simple illustration of one way to convert a speech signal from one sample rate to another. In this model, the data is first sampled at 22,050 Hz and then resampled at 8000 Hz. If you listen to the output, you can hear that the high frequency content has been removed from the signal, although the speech sounds basically the same.
An error is generated when the relation between K and L shown above is not satisfied.
(Input port width)/(Output port width) must equal the (Decimation factor)/(Interpolation factor).
A warning is generated when L and K are not relatively prime; that is, when the ratio L/K can be reduced to a ratio of smaller integers.
Warning: Integer conversion factors are not relatively prime in block 'modelname/FIR Rate Conversion (Frame)'. Converting ratio L/M to l/m.
The block scales the ratio to be relatively prime and continues the simulation.
The FIR Rate Conversion 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 Rate Conversion 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 Rate Conversion block dialog appears as follows when Dialog parameters is selected in the Coefficient source group box.

Specify the integer factor, L, by which to upsample the signal before filtering.
Specify the FIR filter coefficients in descending powers of z.
Specify the integer factor, K, by which to downsample the signal after filtering.
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 Rate Conversion 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 coefficients do not obey the Round integer calculations toward and the Saturate on integer overflow 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 is 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 Rate Conversion 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.
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 Rate Conversion 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.
[1] Orfanidis, S. J. Introduction to Signal Processing. Prentice Hall, 1996.
| Port | Supported Data Types |
|---|---|
Input |
|
Output |
|
| Downsample | Signal Processing Blockset |
| FIR Decimation | Signal Processing Blockset |
| FIR Interpolation | Signal Processing Blockset |
| Upsample | Signal Processing Blockset |
| fir1 | Signal Processing Toolbox |
| fir2 | Signal Processing Toolbox |
| firls | Signal Processing Toolbox |
| upfirdn | Signal Processing Toolbox |
See the following sections for related information:
![]() | FIR Interpolation | Flip | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |