Engee documentation

Downsample

Reduces the sampling frequency of the input signal by removing intermediate values.

blockType: Downsample

Path in the library:

/Signal Operations/Signal Operations/Downsample

Description

The Downsample block reduces the sampling rate of the input signal by removing intermediate values. In the frame-based signal processing mode, the block treats each input element as a separate channel and resamples each such channel separately. When the block performs sample-based processing, the block treats each input element as a separate channel and resamples each channel of the input array over time. The output sampling rate is times lower than the input sampling rate, where is the value of the parameters Downsample factor, M. The Downsample block resamples the input by discarding values after each output value.

Ports

Input

# IN_1 — input signal
vector | matrix | N-dimensional array

Details

An input signal whose sampling rate needs to be reduced.

The unit supports variable-size input signals when the Input processing parameters are set to and is set to . Columns as channels (frame based)`and the Rate options parameters are set to `Enforce single-rate processing. That is, the frame length (number of rows) and the number of channels (columns) can be changed during simulation. When the block accepts variable size input signals, they can have arbitrary frame length. That is, the input frame length does not necessarily have to be a multiple of the downsampling factor. When you specify fixed-size signals, the frame length can be arbitrary under certain conditions.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool.

Complex numbers support

Yes

Output

# OUT_1 — output signal
vector | matrix

Details

An output signal with a sampling rate that is times lower than the input sampling rate.

When parameters Rate options is set to:

  • Enforce single-rate processing, the unit maintains the input sampling rate and lowers the sampling rate of the signal, reducing the output frame size by times.

    The output is sized to for an input of size to .

  • Allow multirate processing, then the block downsamples the signal so that the output sampling rate is times smaller than the input sampling rate.

    The output frame size is the same as the input frame size.

Data types

Float64.

Complex numbers support

Yes

Parameters

Parameters

# Downsample factor, M — downsampling factor
Real or complex number

Details

Integer coefficient , specifying the ratio of the input sampling rate to the output sampling rate.

Default value

2

Program usage name

DownsampleFactor

Tunable

No

Evaluatable

Yes

# Sample offset, [0, M-1] — sampling bias
Real or complex number

Details

The parameters Sample offset, [0, M-1] delays the output samples by an integer number of sample periods , where , so that any of the possible output phases can be selected. For example, by downsampling the sequence 1, 2, 3,…​ by a factor of 4, one of four phases can be selected.

Input sequence

Sampling offset,

Output sequence ( )

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 last three output sequences in the table is the result of setting the Initial conditions parameter to 0 by default. For details on the Initial conditions parameters, refer to [Delay]. Delay.

Default value

0

Program usage name

SampleOffset

Tunable

No

Evaluatable

Yes

# Input processing — specifying processing on the basis of a sample or frame
Columns as channels (frame based) | Elements as channels (sample based)

Details

Specify the input processing method:

  • Columns as channels (frame based) - the block processes each of the input columns as a separate channel containing consecutive time samples. The block downsamples each channel independently, discarding rows of the input matrix after each row it outputs.

  • Elements as channels (sample based) - The block treats each input element as a separate channel and resamples each input channel over time. The block downsamples the input array by discarding samples after each sample it passes through to the output. The input and output dimensions of the Downsample block are identical. In this mode, the input can have the dimensionality of a -dimensional array.

Values

Columns as channels (frame based) | Elements as channels (sample based)

Default value

Elements as channels (sample based)

Program usage name

InputProcessing

Tunable

No

Evaluatable

No

# Rate options — enable single-speed or enable multi-speed processing
Enforce single-rate processing | Allow multirate processing

Details

Specify the method by which the block adjusts the output speed to accommodate a reduced number of samples. The behaviour of this parameter depends on the value for the parameters Input processing: Elements as channels (sample based) (sample-based processing mode) or Columns as channels (frame based) (frame-based processing mode).

  • Elements as channels (sample based)

    • Enforce single-rate processing

      The block forces the output sampling rate to match the input sampling rate (Tso = Tsi) by repeating each Mth input sample M times at the output. In this mode, the block behaves like a Sample and Hold block with a repeating trigger event with period .

    • Allow multirate processing

      The sampling period of the output is times the sampling period of the input ( ).

      For details, refer to. Sampling-based processing.

  • Columns as channels (frame based)

    • `Enforce single rate processing.

      The block generates an output signal at a lower (downsampled) rate using a proportionally smaller frame size than the input. The upper bound on the output size is , where is the input frame length and is the downsampling factor. The input and output frame rates are equal.

    • Allow multirate processing

      The unit generates the output signal at a lower (downsampled) rate using a proportionally larger frame period on the output port than on the input port. At downsampling times, the output frame period is times the input frame period ( ), but the input and output frame sizes are equal.

      For more details, see. Frame-based processing.

      Values

      Enforce single-rate processing | Allow multirate processing

      Default value

      Allow multirate processing

      Program usage name

      RateOptions

      Tunable

      No

      Evaluatable

      No

# Initial condition — initial value
Scalar / array of real and/or complex numbers

Details

Initial value for non-zero delay cases. You can specify a scalar or array of the same size as the input data.

Dependencies

This parameter is not used when the Input processing parameter is set to the value of Columns as channels (frame based), and the Rate options parameters are set to Enforce single-rate processing.

Default value

0

Program usage name

InitialCondition

Tunable

No

Evaluatable

Yes

Read More

Frame-based processing

Details

When you set the parameter Input processing to Columns as channels (frame based) and use an input signal of size to , the block processes each of the input columns as a separate channel containing consecutive time samples. The block downsamples each channel independently, discarding rows of the input matrix after each row it outputs.

In this mode, the block can perform either single-rate or multirate processing. You can use the parameters Rate options, to specify how the block adjusts the output speed to accommodate reduced sampling.

  • When you set the Rate options parameters to a value of `Enforce single-rate processing`parameter, the block generates output data at a slower rate (lower sampling rate) using a proportionally smaller frame size than the input.

    The output data is the size of the upper bound , where is the length of the input frame and is the downsampling factor specified in the parameters Downsample factor, M.

  • When you set the parameters Rate options to Allow multirate processing, the input and output of the Downsample block are the same size, but the output sampling rate is times slower than the input. In this mode, the block treats the matrix input to as independent channels.

    In this mode, the block accepts only fixed-size signals, and these signals can have arbitrary frame lengths.

Sample-based processing

Details

When you set the parameters Input processing to Elements as channels (sample based), the block treats the input matrix to as independent channels and resamples each channel over time. The sampling period of the output signal ( ) is times longer than the sampling period of the input signal ( ), and the input and output sizes are identical.

In this mode, the unit only accepts fixed-size signals, and these signals can have arbitrary frame lengths.

Delay

Details

The delay between the input and output of a block is measured in samples or frames.

The Downsample block has zero delay in the following cases:

  • The downsampling factor of is 1.

  • The parameters Input processing is set to 1. Columns as channels (frame based), and the parameters Rate options is set to 1. Enforce single-rate processing.

  • Parameters Input processing is set to . Columns as channels (frame based), the parameter Rate options is set to . Allow multirate processing, the Sample offset (0 to M-1) parameter, , is set to 0 and the input frame size is set to 1.

  • The parameters Input processing is set to. Elements as channels (sample based)`and the Sample offset (0 to M-1) parameter, , is set to `0.

Zero delay means that the block propagates the input sample (received at time ) as the first output sample, followed by the input sample , the input sample , and so on. If the delay is zero, the block ignores the value of the parameter Initial condition.

In all other cases, the delay is not zero:

  • When the parameters Input processing is set to Elements as channels (sample based), the delay is one sample.

  • When Input processing is set to Columns as channels (frame based) and the input frame size is greater than one, the delay is one frame.

In all cases of one-sample delay, the initial condition for each channel is displayed as the first output sample. The input sample is displayed as the second output sample for each channel, followed by the input sample , the input sample , and so on. The Initial condition parameters can be an array of the same size as the input, or a scalar to be applied to all channels of the signal.

In all cases of one-frame delays, the rows of the initial condition matrix appear sequentially as the first of the output rows. The input sample (row of the input matrix) appears in the output as sample , followed by input sample , input sample , and so on. The parameters Initial condition can be a matrix of size by , containing a single value for each channel, or a scalar to be repeated for all elements of the matrix by .