Products & Services Solutions Academia Support User Community Company

Learn more about Signal Processing Blockset   

Downsample - Resample input at lower rate by deleting samples

Library

Signal Operations

dspsigops

Description

The Downsample block decreases the sampling rate of the input by deleting samples. When the input is a frame-based Mi-by-N matrix, the block resamples each channel of the input independently. When the input is a sample-based N-D array, the Downsample block resamples the input array across time. The resample rate is K times lower than the input sample rate, where K is an integer specified by the Downsample factor parameter. The Downsample block resamples the input by discarding K–1 consecutive samples following each sample that is passed through to the output.

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 SequenceSample Offset, DOutput Sequence (K=4)

1,2,3,...

0

1,5,9,13,17,21,25,29,...

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 of the latter three output sequences in the table is a result of the default zero Initial condition parameter setting for this example. See Latency for more information 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 a sample-based N-D array, the Downsample block resamples the input across time. The block downsamples the input array by discarding K–1 samples following each sample that it passes through to the output. The input and output sizes of the Downsample block 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 parameter 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

The Downsample block has zero-tasking latency in the following cases:

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.

In all other cases, the latency is nonzero:

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 array of the same size as the input, 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 containing one value for each channel, or a scalar to be repeated across all elements of the Mi-by-N matrix. See the following example for an illustration of this case.

Examples

Construct this frame-based model.

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, open the Configuration Parameters dialog box. From the list on the left side of the dialog box, click Solver. From the Type list, select Fixed-step, and from the Solver list, select Discrete (no continuous states). From the Tasking mode for periodic sample times list, select MultiTasking. Additionally, set the Stop time parameter to 30.

Run the model and look at the output, yout. The first few samples of each channel are shown:

yout =
    11   -11
    12   -12
    13   -13
    14   -14
     2    -2
     4    -4
     6    -6
     8    -8
    10   -10
    12   -12
    14   -14

Since you 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 (row D+1, where D is the Sample offset) appears in the output as sample 5 (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 value or an array of the same size as the input.

Sample-based mode

The method by which to implement downsampling for sample-based inputs: Allow multirate (decrease the output sample rate), or Force single-rate (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 (decrease the frame rate), or Maintain input frame rate (decrease the frame size).

Supported Data Types

PortSupported Data Types

Input

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed and unsigned)

  • Boolean

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Output

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed and unsigned)

  • Boolean

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

See Also

FIR DecimationSignal Processing Blockset
FIR Rate ConversionSignal Processing Blockset
RepeatSignal Processing Blockset
Sample and HoldSignal Processing Blockset
UpsampleSignal Processing Blockset

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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