Description
The FIR Interpolation block resamples the discrete-time input at a rate
L times faster than the input sample rate, where
L is the integer value you specify for the
Interpolation factor parameter. To do so, the block implements
a polyphase filter structure and performs the following operations:
The block uses a polyphase filter implementation because it is more efficient than
straightforward upsample-then-filter algorithms. See Fliege [1] for more
information.
You can use the FIR Interpolation block inside triggered subsystems when you set the
Rate options parameter to Enforce single-rate
processing
.
Specifying the Filter Coefficients
To specify the filter coefficients, select the mode you want the FIR Interpolation
block to operate in. Select the mode in the Coefficient source
group box.
Dialog parameters — Enter information
about the filter, such as coefficients in the block dialog box.
Input port — Specify the filter
coefficients as an input to the block. Coefficient values are tunable
(can change during simulation), while their properties must remain
constant.
Filter object — Specify the filter using a
dsp.FIRInterpolator
System
object™.
Auto (default) — Choose the filter
coefficients of an FIR Nyquist filter, predesigned for the interpolation
factor specified in the block dialog box.
When you select Dialog parameters, you use the FIR
filter coefficients parameter to specify the numerator coefficients
of the FIR filter transfer function
H(z).
You can generate the FIR filter coefficient vector, [b(1) b(2) ...
b(m)]
, using one of the DSP System
Toolbox™ filter design functions such as designMultirateFIR
, firnyquist
, firhalfband
, firgr
or firceqrip
.
The filter you specify must be a lowpass filter with a length greater than the
interpolation factor (m>L) and a normalized cutoff frequency
no greater than 1
/L. The block internally initializes all filter states to
zero.
When you select Auto, the block designs an FIR interpolator
with the interpolation factor specified in Interpolation
factor. The designMultirateFIR
function designs
the filter and returns the coefficients used by the block. For more information on
the filter design, see Orfanidis [2].
Frame-Based Processing
When you set the Input processing parameter to
Columns as channels (frame based)
, the block
resamples each column of the input over time. In this mode, the block can perform
either single-rate or multirate processing. You can use the Rate
options parameter to specify how the block resamples the
input:
When you set the Rate options parameter to
Enforce single-rate processing
, the input and
output of the block have the same sample rate. To interpolate the output
while maintaining the input sample rate, the block resamples the data in
each column of the input such that the frame size of the output
(Mo) is
L times larger than that of the input
(Mo =
Mi*L).
For an example of single-rate FIR Interpolation, see Example 1 — Single-Rate Processing.
When you set the Rate options parameter to
Allow multirate processing
, the input and
output of the FIR Interpolation block are the same size. However, the sample
rate of the output is L times faster than that of the
input. In this mode, the block treats an
Mi-by-N
matrix input as N independent channels. The block
interpolates each column of the input over time by keeping the frame size
constant
(Mi=Mo),
while making the output frame period
(Tfo) L
times shorter than the input frame period
(Tfo =
Tfi/L).
See Example 2 — Multirate Frame-Based Processing for an
example that uses the FIR Interpolation block in this mode.
Sample-Based Processing
When you set the Input processing parameter to
Elements as channels (sample based)
, the block treats
an M-by-N matrix input as
M*N independent channels, and interpolates
each channel over time. The output sample period
(Tso) is L
times shorter than the input sample period
(Tso =
Tsi/L), while
the input and output sizes remain identical.
Latency
When you run your models in Simulink®
SingleTasking
mode or set the Input
processing parameter to Columns as channels (frame
based)
and the Rate options parameter to
Enforce single-rate processing
, the FIR Interpolation
block always has zero-tasking latency. Zero-tasking latency
means that the block propagates the first filtered input sample (received at time
t=0
) as the first output sample. That
first output sample is then followed by L–1
interpolated values, the second filtered input sample, and so on.
The only time the FIR Interpolation block exhibits latency is when you set the
Rate options parameter set to Allow multirate
processing
and run your models in Simulink
MultiTasking
mode. The amount of latency for multirate,
multitasking operation depends on the setting of the Input
processing parameter, as shown in the following table.
Input processing | Latency |
---|
Elements as channels (sample
based)
| L samples |
Columns as channels (frame
based)
| L frames
(Mi samples
per frame) |
When the block exhibits latency, the default initial condition is zero.
Alternatively, you can use the Output buffer initial conditions
parameter to specify a matrix of initial conditions containing one value for each
channel or a scalar initial condition to be applied to all channels. The block
scales the Output buffer initial conditions by the
Interpolation factor and outputs the scaled initial
conditions until the first filtered input sample becomes available.
When the block is in sample-based processing mode, the block outputs the scaled
initial conditions at the start of each channel, followed immediately by the first
filtered input sample, then L–1 interpolated values, and so on.
When the block is in frame-based processing mode and using the default initial
condition of zero, the first
Mi*L 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*L+1
.
That value is then followed by L–1 interpolated values, the
second filtered input sample, and so on.
Fixed-Point Data Types
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 box as discussed in Dialog Box section. This diagram shows
that input data is stored in the input buffer with the same data type and scaling as
the input. The block stores filtered data and any initial conditions in the output
buffer using the output data type and scaling that you set in the block dialog
box.
When at least one of the inputs to the multiplier is real, the output of the
multiplier is in the product output data type. When both inputs to the multiplier
are complex, the result of the multiplication is in the accumulator data type. For
details on the complex multiplication performed by this block, see Multiplication Data Types.
Note
When the block input is fixed point, all internal data types are signed fixed
point.
Examples
Example 1 — Single-Rate Processing
In the ex_firinterpolation_ref2, the FIR Interpolation block interpolates a
single-channel input with a frame size of 16
. Because the block
is doing single-rate processing and the Interpolation factor
parameter is set to 4
, the output of the FIR Interpolation block
has a frame size of 64
. As shown in the following figure, the
input, and output of the FIR Interpolation block have the same sample rate.
Example 2 — Multirate Frame-Based Processing
In the ex_firinterpolation_ref1, the FIR Interpolation block interpolates a
single-channel input with a frame period of 1 second (Sample
time = 1/64
and Samples per
frame = 64
). Because the block is doing multirate
frame-based processing and the Interpolation factor parameter
is set to 4
, the output of the FIR Interpolation block has a
frame period of 0.25
seconds. As shown in the following figure,
the input and output of the FIR Interpolation block have the same frame size, but
the sample rate of the output is 1/4
times that of the
input.
Example 3
The ex_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 matches
the output of the Polyphase Interpolation Filter block.
Example 4
The ex_mrf_nlp
model illustrates the use of the FIR Interpolation block in a number of multistage
multirate filters.
Dialog Box
Coefficient Source
The FIR Interpolation block can operate in four different modes. Select the mode
in the Coefficient source group box.
Dialog parameters — Enter information about
the filter, such as coefficients, in the block mask.
Input port — Specify the filter coefficients
with a Num input port. The Num
input port appears when you select the Input port
option. Coefficient values obtained through Num are
tunable (can change during simulation), while their properties must remain
constant.
Filter object — Specify the filter using a
dsp.FIRInterpolator
System
object.
Auto (default) — Choose the coefficients of an
FIR Nyquist filter, predesigned for the Interpolation factor specified in
the block dialog box.
Different items appear on the FIR Interpolation block dialog box
depending on whether you select Dialog parameters,
Input port, Filter object, or
Auto in the Coefficient source group
box.
Specify Filter Characteristics in dialog box
The pane of the FIR Interpolation block dialog
box appears as follows when you select Dialog parameters in
the Coefficient source group box.
- FIR filter
coefficients
Specify the FIR filter coefficients, in descending powers of
z. By default,
designMultirateFIR(3,1)
computes the filter
coefficients.
- Interpolation factor
Specify the integer factor, L, by which to
increase the sample rate of the input sequence. The default is
3
.
- Input processing
Specify how the block should process the input. You can set
this parameter to one of the following options:
Columns as channels (frame based)
(default)
— When you select this option, the block treats each column
of the input as a separate channel.
Elements as channels (sample based)
—
When you select this option, the block treats each element of the
input as a separate channel.
- Rate
options
Specify the method by which the block should interpolate the
input. You can select one of the following options:
Enforce single-rate
processing
— When you select
this option, the block maintains the input sample rate,
and interpolates the signal by increasing the output
frame size by a factor of L. To
select this option, you must set the Input
processing parameter to
Columns as channels (frame
based)
.
Allow multirate processing
— When you select this option, the block
interpolates the signal such that the output sample rate
is L times faster than the input
sample rate.
- Output buffer initial
conditions
In cases of nonzero latency, the block divides this parameter by
the Interpolation factor and outputs the
results at the output port until the first filtered input sample is
available. The default initial condition value is
0
, but you can enter a matrix containing one
value for each channel, or a scalar to be applied to all signal
channels. This parameter appears only when you configure the block
to perform multirate processing.
Output buffer initial conditions are stored in the output data
type and scaling.
See Latency for more information
about latency in the FIR Interpolation block.
- View filter response
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.
The pane of the FIR Interpolation block
dialog box appears as follows when you select Dialog
parameters in the Coefficient source group
box.
- Rounding mode
Select the rounding
mode for fixed-point operations. The default is
Floor
. The filter coefficients do not
obey this parameter; they always round to
Nearest
.
Note
The Rounding mode and Saturate
on integer overflow settings have no effect on
numerical results when all the following conditions exist:
Product output is
Inherit: Inherit via internal
rule
Accumulator is
Inherit: Inherit via internal
rule
Output is
Inherit: Same as
accumulator
With these data type settings, the block is effectively
operating in full precision mode.
- Saturate on
integer overflow
When you select this parameter, the block saturates the result of
its fixed-point operation. When you clear this parameter, the block
wraps the result of its fixed-point operation. For details on
saturate
and wrap
, see
overflow
mode for fixed-point operations.
Note
The Rounding mode and Saturate
on integer overflow parameters have no effect on
numeric results when all these conditions are met:
With these data type settings, the block operates in
full-precision mode.
- Coefficients
Specify the coefficients data type. See Fixed-Point Data Types and
Multiplication Data Types
for illustrations depicting the use of the coefficients data type in
this block. You can set it to:
A rule that inherits a data type, for example,
Inherit: Same word length as
input
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Coefficients parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
- Coefficients Minimum
Specify the minimum value of the filter coefficients. The default
value is []
(unspecified). Simulink software uses this value to perform:
- Coefficients Maximum
Specify the maximum value of the filter coefficients. The default
value is []
(unspecified). Simulink software uses this value to perform:
- Product output
Specify the product output data type. See Fixed-Point Data Types and
Multiplication Data Types
for illustrations depicting the use of the product output data type
in this block. You can set it to:
A rule that inherits a data type, for example,
Inherit: Inherit via internal
rule
. For more information on this rule,
see Inherit via Internal Rule.
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Product output parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
- Accumulator
Specify the accumulator data type. See Fixed-Point Data Types for
illustrations depicting the use of the accumulator data type in this
block. You can set this parameter to:
A rule that inherits a data type, for example,
Inherit: Inherit via internal
rule
. For more information on this rule,
see Inherit via Internal Rule.
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Accumulator parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
- Output
Specify the output data type. See Fixed-Point Data Types for
illustrations depicting the use of the output data type in this
block. You can set it to:
A rule that inherits a data type, for example,
Inherit: Same as
accumulator
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Output parameter.
See Control Signal Data Types (Simulink) for more information.
- Output Minimum
Specify the minimum value that the block should output. The
default value is []
(unspecified). Simulink software uses this value to perform:
- Output Maximum
Specify the maximum value that the block should output. The
default value is []
(unspecified). Simulink software uses this value to perform:
- Lock
data type settings against changes by the fixed-point tools
Select this parameter to prevent the fixed-point tools from
overriding the data types you specify on the block mask.
Provide Filter Coefficients Through Input Port
The pane of the FIR Interpolation block dialog
box appears as follows when you select Input port in the
Coefficient source group box.
- Interpolation factor
Specify the integer factor, L, by which to
increase the sample rate of the input sequence. The default is
3
.
- Input processing
Specify how the block should process the input. You can set
this parameter to one of the following options:
Columns as channels (frame based)
(default)
— When you select this option, the block treats each column
of the input as a separate channel.
Elements as channels (sample based)
—
When you select this option, the block treats each element of the
input as a separate channel.
- Rate options
Specify the method by which the block should interpolate the
input. You can select one of the following options:
Enforce single-rate
processing
— When you select
this option, the block maintains the input sample rate,
and interpolates the signal by increasing the output
frame size by a factor of L. To
select this option, you must set the Input
processing parameter to
Columns as channels (frame
based)
.
Allow multirate processing
— When you select this option, the block
interpolates the signal such that the output sample rate
is L times faster than the input
sample rate.
- Output buffer initial
conditions
In cases of nonzero latency, the block divides this parameter by
the Interpolation factor and outputs the
results at the output port until the first filtered input sample is
available. The default initial condition value is
0
, but you can enter a matrix containing one
value for each channel, or a scalar to be applied to all signal
channels. This parameter appears only when you configure the block
to perform multirate processing.
Output buffer initial conditions are stored in the output data
type and scaling.
See Latency for more information
about latency in the FIR Interpolation block.
The pane of the FIR Interpolation block
dialog box appears as follows when you select Input port in
the Coefficient source group box.
- Rounding mode
Select the rounding
mode for fixed-point operations. The default is
Floor
. The filter coefficients do not
obey this parameter; they always round to
Nearest
.
Note
The Rounding mode and Saturate
on integer overflow settings have no effect on
numerical results when all the following conditions exist:
Product output is
Inherit: Inherit via internal
rule
Accumulator is
Inherit: Inherit via internal
rule
Output is
Inherit: Same as
accumulator
With these data type settings, the block is effectively
operating in full precision mode.
- Saturate on integer overflow
When you select this check box, the block saturates the result of
its fixed-point operation. When you clear this check box, the block
wraps the result of its fixed-point operation. By default, this
check box is cleared. For details on saturate
and
wrap
, see overflow
mode for fixed-point operations. The filter coefficients
do not obey this parameter; they are always saturated.
- Product output
Specify the product output data type. See Fixed-Point Data Types and
Multiplication Data Types
for illustrations depicting the use of the product output data type
in this block. You can set it to:
A rule that inherits a data type, for example,
Inherit: Inherit via internal
rule
. For more information on this rule,
see Inherit via Internal Rule.
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Product output parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
- Accumulator
Specify the accumulator data type. See Fixed-Point Data Types for
illustrations depicting the use of the accumulator data type in this
block. You can set this parameter to:
A rule that inherits a data type, for example,
Inherit: Inherit via internal
rule
. For more information on this rule,
see Inherit via Internal Rule.
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Accumulator parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
- Output
Specify the output data type. See Fixed-Point Data Types for
illustrations depicting the use of the output data type in this
block. You can set it to:
A rule that inherits a data type, for example,
Inherit: Same as
accumulator
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Output parameter.
See Control Signal Data Types (Simulink) for more information.
- Output Minimum
Specify the minimum value that the block should output. The
default value is []
(unspecified). Simulink software uses this value to perform:
- Output Maximum
Specify the maximum value that the block should output. The
default value is []
(unspecified). Simulink software uses this value to perform:
- Lock
data type settings against changes by the fixed-point tools
Select this parameter to prevent the fixed-point tools from
overriding the data types you specify on the block mask.
Specify Multirate Filter Object
The pane of the FIR Interpolation block dialog
box appears as follows when you select Filter object in the
Coefficient source group box.
- Filter
object
Specify the name of the multirate filter object that you want the
block to implement. You must specify the filter as a dsp.FIRInterpolator
System
object.
You can define the System
object in the block mask or in a MATLAB® workspace variable.
For information on creating System objects, see Define Basic System Objects (MATLAB).
- Input processing
Specify how the block should process the input. You can set
this parameter to one of the following options:
Columns as channels (frame based)
(default)
— When you select this option, the block treats each column
of the input as a separate channel.
Elements as channels (sample based)
—
When you select this option, the block treats each element of the
input as a separate channel.
- Rate options
Specify the method by which the block should interpolate the
input. You can select one of the following options:
Enforce single-rate
processing
— When you select
this option, the block maintains the input sample rate,
and interpolates the signal by increasing the output
frame size by a factor of L. To
select this option, you must set the Input
processing parameter to
Columns as channels (frame
based)
.
Allow multirate processing
— When you select this option, the block
interpolates the signal such that the output sample rate
is L times faster than the input
sample rate.
This button opens the Filter Visualization Tool (fvtool
) from the
Signal
Processing Toolbox product and displays the filter response of the
System
object specified in the Filter object
parameter. For more information on FVTool, see the Signal
Processing Toolbox documentation.
Note
If you specify a filter in the Filter
object parameter, you must apply the filter by
clicking the Apply button before using
the View filter response button.
The pane of the FIR Interpolation block
dialog box appears as follows when you select Filter object
in the Coefficient source group box.
The fixed-point settings of the filter object specified on the
pane are displayed on the pane. You cannot change these settings directly on the
block mask. To change the fixed-point settings, edit the filter object
directly.
For more information on System objects, see Define Basic System Objects (MATLAB).
Choose Filter Coefficients Automatically
When you select Auto in the Coefficient
source group box, the block chooses the filter coefficients
automatically. For more information on the filter design algorithm the block
uses, see Specifying the Filter Coefficients.
The pane of the FIR Interpolation block dialog
box appears as follows when you select Auto in the
Coefficient source group box.
- Interpolation factor
Specify the integer factor, L, by which to
increase the sample rate of the input sequence. The default is
3
.
- Input processing
Specify how the block should process the input. You can set
this parameter to one of the following options:
Columns as channels (frame based)
(default)
— When you select this option, the block treats each column
of the input as a separate channel.
Elements as channels (sample based)
—
When you select this option, the block treats each element of the
input as a separate channel.
- Rate options
Specify the method by which the block should interpolate the
input. You can select one of the following options:
Enforce single-rate
processing
— When you select
this option, the block maintains the input sample rate,
and interpolates the signal by increasing the output
frame size by a factor of L. To
select this option, you must set the Input
processing parameter to
Columns as channels (frame
based)
.
Allow multirate processing
— When you select this option, the block
interpolates the signal such that the output sample rate
is L times faster than the input
sample rate.
- Output buffer initial
conditions
In cases of nonzero latency, the block divides this parameter by
the Interpolation factor and outputs the
results at the output port until the first filtered input sample is
available. The default initial condition value is
0
, but you can enter a matrix containing one
value for each channel, or a scalar to be applied to all signal
channels. This parameter appears only when you configure the block
to perform multirate processing.
Output buffer initial conditions are stored in the output data
type and scaling.
See Latency for more information
about latency in the FIR Interpolation block.
- View filter
response
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.
The pane of the FIR Interpolation block
dialog box appears as follows when you select Auto in the
Coefficient source group box.
- Rounding mode
Select the rounding
mode for fixed-point operations. The default is
Floor
. The filter coefficients do not
obey this parameter; they always round to
Nearest
.
Note
The Rounding mode and Saturate
on integer overflow settings have no effect on
numerical results when all the following conditions exist:
Product output is
Inherit: Inherit via internal
rule
Accumulator is
Inherit: Inherit via internal
rule
Output is
Inherit: Same as
accumulator
With these data type settings, the block is effectively
operating in full precision mode.
- Saturate on integer overflow
When you select this check box, the block saturates the result of
its fixed-point operation. When you clear this check box, the block
wraps the result of its fixed-point operation. By default, this
check box is cleared. For details on saturate
and
wrap
, see overflow
mode for fixed-point operations. The filter coefficients
do not obey this parameter; they are always saturated.
- Coefficients
Specify the coefficients data type. See Fixed-Point Data Types and
Multiplication Data Types
for illustrations depicting the use of the coefficients data type in
this block. You can set it to:
A rule that inherits a data type, for example,
Inherit: Same word length as
input
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Coefficients parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
- Coefficients Minimum
Specify the minimum value of the filter coefficients. The default
value is []
(unspecified). Simulink software uses this value to perform:
- Coefficients Maximum
Specify the maximum value of the filter coefficients. The default
value is []
(unspecified). Simulink software uses this value to perform:
- Product output
Specify the product output data type. See Fixed-Point Data Types and
Multiplication Data Types
for illustrations depicting the use of the product output data type
in this block. You can set it to:
A rule that inherits a data type, for example,
Inherit: Inherit via internal
rule
. For more information on this rule,
see Inherit via Internal Rule.
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Product output parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
- Accumulator
Specify the accumulator data type. See Fixed-Point Data Types for
illustrations depicting the use of the accumulator data type in this
block. You can set this parameter to:
A rule that inherits a data type, for example,
Inherit: Inherit via internal
rule
. For more information on this rule,
see Inherit via Internal Rule.
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Accumulator parameter.
See Specify Data Types Using Data Type Assistant (Simulink) for more information.
- Output
Specify the output data type. See Fixed-Point Data Types for
illustrations depicting the use of the output data type in this
block. You can set it to:
A rule that inherits a data type, for example,
Inherit: Same as
accumulator
An expression that evaluates to a valid data type, for
example, fixdt(1,16,0)
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the
Output parameter.
See Control Signal Data Types (Simulink) for more information.
- Output Minimum
Specify the minimum value that the block should output. The
default value is []
(unspecified). Simulink software uses this value to perform:
- Output Maximum
Specify the maximum value that the block should output. The
default value is []
(unspecified). Simulink software uses this value to perform:
- Lock
data type settings against changes by the fixed-point tools
Select this parameter to prevent the fixed-point tools from
overriding the data types you specify on the block mask.