DSP Blockset Previous page   Next Page
Downsample

Resample an input at a lower rate by deleting samples

Library

Signal Operations

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.

Input Sequence
Sample Offset, D
Output Sequence (K=4)
1,2,3,...
0
0,1,5,9,13,17,21,25,...
1,2,3,...
1
0,2,6,10,14,18,22,26,...
1,2,3,...
2
0,3,7,11,15,19,23,27,...
1,2,3,...
3
0,4,8,12,16,20,24,28,...

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.

This block supports triggered subsystems if, for Sample-based mode, you select Force single-rate and, for Frame-based mode, you select Maintain input frame rate.

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 pop-up 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 setting of the Sample-based mode pop-up 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.

Input Sampling
Parameter Settings
Sample-based
Downsample factor parameter, K, is 1, or
Enforce single rate is selected (with D=0)
Frame-based
Downsample factor parameter, K, is 1, or
Maintain input frame rate is selected

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 Force 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) for more information about block rates and the Simulink tasking modes.

Examples

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 (that is, row D+1, where D is the Sample offset) appears in the output as sample 5 (that is sample Mi+1, where Mi is the input frame size).

Dialog Box

Downsample factor
The integer factor, K, by which to decrease the input sample rate.
Sample offset
The sample offset, D, which must be an integer in the range [0, K-1].
Initial condition
The value with which the block is initialized for cases of nonzero latency; a scalar or matrix.
Sample-based mode
The method by which to implement downsampling for sample-based inputs: Allow multirate (that is, decrease the output sample rate), or Force single-rate (that is, force the output sample rate to match the input sample rate by repeating every Kth input sample K times at the output).
Frame-based mode
The method by which to implement downsampling for frame-based inputs: Maintain input frame size (that is, decrease the frame rate), or Maintain input frame rate (that is, decrease the frame size).

Supported Data Types

To learn how to convert your data types 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


Previous page  Discrete Impulse DSP Constant Next page

Learn more about the latest releases of MathWorks products:

 © 1994-2010 The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS