Filter and downsample input signals
Filtering / Multirate Filters
dspmlti4
The FIR Decimation block resamples the discretetime input at a rate K times slower than the input sample rate, where K is the integer value you specify for the Decimation factor parameter. To do so, the block implements a polyphase filter structure and performs the following operations:
Filters the data in each channel of the input using a directform FIR filter.
Downsamples each channel of filtered data by discarding K–1 consecutive samples following each sample that is retained.
The block uses a polyphase filter implementation because it is more efficient than straightforward filterthendecimate algorithms. See Fliege [1] for more information.
You can use the FIR Decimation block inside triggered subsystems when you set the
Rate options parameter to Enforce singlerate
processing
.
This block supports variablesize input. This means that while the block is simulating, the frame size (number of rows) can change. The output dimensions always equal those of the input signal.
To specify the filter coefficients, select the mode you want the FIR Decimation block to operate in. Select the mode in the Coefficient source group box.
Dialog parameters — Enter information about the filter, such as structure and 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.FIRDecimator
System
object™.
Auto (default) — Choose the filter coefficients of an FIR Nyquist filter, predesigned for the decimation 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).
$$H(z)=B(z)={b}_{1}+{b}_{2}{z}^{1}+\dots +{b}_{m}{z}^{(m1)}$$
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 normalized cutoff frequency no greater than 1/K. The block internally initializes all filter states to zero.
When you select Auto, the block designs an FIR decimator with
the decimation factor specified in Decimation 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].
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 singlerate 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 singlerate processing
, the input and
output of the block have the same sample rate. To decimate 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
(M_{o}) is
1/K times that of the input
(M_{o} =
M_{i}/K),
In this mode, the input frame size, M_{i}, must be a multiple of the Decimation factor, K.
For an example of singlerate FIR Decimation, see Example 1 — SingleRate Processing.
When you set the Rate options parameter to
Allow multirate processing
, the input and
output of the FIR Decimation block are the same size, but the sample rate of
the output is K times slower than that of the input. In
this mode, the block treats an
M_{i}byN
matrix input as N independent channels. The block
decimates each column of the input over time by keeping the frame size
constant
(M_{i}=M_{o}),
and making the output frame period
(T_{fo}) K
times longer than the input frame period
(T_{fo} =
K*T_{fi}).
See Example 2— Multirate FrameBased Processing for an example that uses the FIR Decimation block in this mode.
When you set the Input processing parameter to
Elements as channels (sample based)
, the block treats
an MbyN matrix input as
M*N independent channels, and decimates
each channel over time. The output sample period
(T_{so}) is K
times longer than the input sample period
(T_{so} =
K*T_{si}), and the input and output
sizes are identical.
When you use the FIR Decimation block in samplebased processing mode, the block always has zerotasking latency. Zerotasking 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 filtered input samples K+1, 2K+1, and so on.
When you use the FIR Decimation block in framebased processing mode with a frame size greater than one, the block may exhibit oneframe latency. Cases of oneframe latency can occur when the input frame size is greater than one, and you set the Input processing and Rate options parameters of the FIR Decimation block as follows:
Input processing = Columns as channels
(frame based)
Rate options = Allow multirate
processing
In cases of oneframe latency, you can define the value of the first
M_{i} output rows by setting the
Output buffer initial conditions parameter. The
default value of the Output buffer initial conditions
parameter is 0
. However, you can enter a matrix containing one
value for each channel of the input, or a scalar value to be applied to all
channels. The first filtered input sample (first filtered row of the input matrix)
appears in the output as sample M_{i}+ 1.
That sample is then followed by filtered input samples K+ 1,
2K+ 1, and so on.
For more information on latency and the Simulink^{®} tasking modes, see Excess Algorithmic Delay (Tasking Latency) and TimeBased Scheduling and Code Generation (Simulink Coder).
The following diagram shows the data types used within the FIR Decimation block for fixedpoint signals.
You can set the coefficient, product output, accumulator, and output data types in the block dialog box as discussed in the Dialog Box section. This diagram shows that 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.
When the block input is fixed point, all internal data types are signed fixedpoint values.
In the ex_firdecimation_ref2 model, the FIR Decimation block decimates a
singlechannel input with a frame size of 64. Because the block is doing singlerate
processing and the Decimation factor parameter is set to
4
, the output of the FIR Decimation block has a frame size of
16. As shown in the following figure, the input, and output of the FIR Decimation
block have the same sample rate.
In the ex_firdecimation_ref1 model, the FIR Decimation block decimates a
singlechannel input with a frame period of one second. Because the block is doing
multirate framebased processing and the Decimation factor
parameter is set to 4
, the frame period of the output is
4
seconds. As shown in the following figure, the input, and
output of the FIR Decimation block have the same frame size, but the sample rate of
the output is four times that of the input.
The ex_polyphasedec
model illustrates the underlying
polyphase implementations of the FIR Decimation block. Run the model, and view the
results on the scope. The output of the FIR Decimation block matches the output of
the Polyphase Decimation Filter block.
The ex_mrf_nlp
model illustrates the use of the FIR Decimation block in several multistage
multirate filters.
The FIR Decimation 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 structure and 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.FIRDecimator
System
object.
Auto (default) — Choose the coefficients of an FIR Nyquist filter, predesigned for the decimation factor specified in the block dialog box.
Different items appear on the FIR Decimation 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
Provide Filter Coefficients Through Input Port
[1] Fliege, N. J. Multirate Digital Signal Processing: Multirate Systems, Filter Banks, Wavelets. West Sussex, England: John Wiley & Sons, 1994.
[2] Orfanidis, Sophocles J. Introduction to Signal Processing. Upper Saddle River, NJ: PrenticeHall, 1996.
Port  Supported Data Types 

Input 

Output 

Downsample  DSP System Toolbox 
FIR Interpolation  DSP System Toolbox 
FIR Rate Conversion  DSP System Toolbox 
CIC Decimation  DSP System Toolbox 
Digital DownConverter  DSP System Toolbox 
FIR Halfband Interpolator  DSP System Toolbox 
FIR Halfband Decimator  DSP System Toolbox 
IIR Halfband Interpolator  DSP System Toolbox 
IIR Halfband Decimator  DSP System Toolbox 
CIC Compensation Interpolator  DSP System Toolbox 
CIC Compensation Decimator  DSP System Toolbox 
Digital UpConverter  DSP System Toolbox 
dsp.FIRDecimator  DSP System Toolbox 
dsp.CICCompensationDecimator  DSP System Toolbox 
dsp.FIRHalfbandDecimator  DSP System Toolbox 
firnyquist  DSP System Toolbox 
firhalfband  DSP System Toolbox 
firgr  DSP System Toolbox 
firceqrip  DSP System Toolbox 