DSP Blockset | ![]() ![]() |
Resample an input at a lower rate by deleting samples.
Library
Description
The Downsample block resamples each channel of the Mi-by-N input at a rate K times lower than the input sample rate by discarding K-1 consecutive samples following each sample passed through to the output. The integer K is specified by the Downsample factor parameter.
The Sample offset parameter delays the output samples by an integer number of sample periods, D, where 0 D < (K-1), so that any of the K possible output phases can be selected. For example, when you downsample the sequence 1, 2, 3, ... by a factor of 4, you can select from the following four phases.
The initial zero in each output sequence above is a result of the default zero Initial condition parameter setting for this example. See Latency for more on the Initial condition parameter.
Sample-Based Operation
When the input is sample-based, the block treats each of the M*N matrix elements as an independent channel, and downsamples each channel over time. The input and output sizes are identical.
The Sample-based mode parameter determines how the block represents the new rate at the output. There are two available options:
The setting of the Frame-based mode popup menu does not affect sample-based inputs.
Frame-Based Inputs
When the input is frame-based, the block treats each of the N input columns as a frame containing Mi sequential time samples from an independent channel. The block downsamples each channel independently by discarding K-1 rows of the input matrix following each row that it passes through to the output.
The Frame-based mode parameter determines how the block adjusts the rate at the output to accommodate the reduced number of samples. There are two available options:
The model below shows a single-channel input with a frame period of 1 second being downsampled by a factor of 4 to a frame period of 4 seconds. The input and output frame sizes are identical.
The model below shows a single-channel input of frame size 64 being downsampled by a factor of 4 to a frame size of 16. The input and output frame rates are identical.
The setting of the Sample-based mode popup menu does not affect frame-based inputs.
Latency
Zero Latency. The Downsample block has zero tasking latency for the special combinations of input signal sampling and parameter settings shown in the table below. In all of these cases the block has single-rate operation.
Zero tasking latency means that the block propagates input sample D+1 (received at t=0) as the first output sample, followed by input sample D+1+K, input sample D+1+2K, and so on. The Initial condition parameter value is not used.
Nonzero Latency. The Downsample block is multirate for most settings other than those in the above table. The amount of latency for multirate operation depends on input signal sampling and the Simulink tasking mode, as shown in the table below.
Multirate... |
Sample-Based Latency |
Frame-Based Latency |
Single-tasking |
None, for D=0 One sample, for D>0 |
One frame (Mi samples) |
Multitasking |
One sample |
One frame (Mi samples) |
The only case of nonzero single-rate latency occurs in sample-based mode, when Enforce single rate is selected with D > 0. The latency in this case is one sample.
In all cases of one-sample latency, the initial condition for each channel appears as the first output sample. Input sample D+1 appears as the second output sample for each channel, followed by input sample D+1+K, input sample D+1+2K, and so on. The Initial condition parameter can be an Mi-by-N matrix containing one value for each channel, or a scalar to be applied to all signal channels.
In all cases of one-frame latency, the Mi rows of the initial condition matrix appear in sequence as the first Mi output rows. Input sample D+1 (i.e, row D+1 of the input matrix) appears in the output as sample Mi+1, followed by input sample D+1+K, input sample D+1+2K, and so on. The Initial condition value can be an Mi-by-N matrix, or a scalar to be repeated across all elements of the Mi-by-N matrix. 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
Construct the frame-based model shown below.
Adjust the block parameters as follows:
This model is multirate because there are at least two distinct frame 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. Additionally, 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 row of the initial condition matrix appears as the first output sample, followed by the other three initial condition rows. The second row of the first input matrix (i.e., row D+1, where D is the Sample offset) appears in the output as sample 5 (i.e., sample Mi+1, where Mi is the input frame size).
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 |
Repeat |
DSP Blockset |
Sample and Hold |
DSP Blockset |
Upsample |
DSP Blockset |
Also see Signal Operations for a list of all the blocks in the Signal Operations library.
![]() | Discrete Impulse | DSP Constant | ![]() |