Engee documentation

Downsample

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

blockType: Downsample

Path in the library:

/Signal Operations/Signal Operations/Downsample

Description

Block Downsample reduces the sampling rate of the input signal by removing intermediate values. In frame-based signal processing mode, the block processes each input element as a separate channel and resamples each such channel separately. When the block performs sample-based processing, it processes each element of the input data as a separate channel and re-selects each channel of the input array over time. The sampling rate at the output in times lower than the sampling rate at the input, where — parameter value Downsample factor, M. Block Downsample 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 — the downsampling factor
Real or complex number

Details

Integer coefficient , which sets the ratio of the sampling rate at the input to the sampling rate at the output.

Default value

2

Program usage name

DownsampleFactor

Tunable

No

Evaluatable

Yes

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

Details

Parameter Sample offset, [0, M-1] delays output samples by an integer number of sampling periods , where , so any of the following can be selected possible output phases. For example, if the sampling of the sequence 1, 2, 3,…​ is reduced by 4 times, one of the four phases can be selected.

The input sequence

Selection bias,

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 the default value of 0. For more information about the Initial conditions parameter, see Delay.

Default value

0

Program usage name

SampleOffset

Tunable

No

Evaluatable

Yes

# Input processing — specifying processing based on 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 reduces the sampling rate of each channel independently, discarding rows of the input matrix after each row that it outputs.

  • Elements as channels (sample based) — the unit processes each input element as a separate channel and performs resampling of each input channel over time. The block lowers the sampling of the input array, discarding samples after each sample through which it passes to the exit. Input and output block sizes Downsample they are identical. In this mode, the input can have a dimension - a dimensional array.

For more information, see Signal processing by frames and counts.

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 allow multi-speed processing
Enforce single-rate processing | Allow multirate processing

Details

Specify the method by which the unit adjusts the output speed to accommodate the reduced number of samples. The behavior of this parameter depends on the value for the parameter 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 recurring trigger event with a period of .

    • Allow multirate processing

      The sampling period of the output in times longer than the sampling period of the input ( ).

      For more information, see Sample-based processing.

  • Columns as channels (frame based)

    • Enforce single rate processing

      The unit generates an output signal at a lower (with a reduced sampling rate) speed, using a proportionally smaller frame size than the input one. The upper limit of the output signal size is , where — the length of the input frame, and — the coefficient of reduction of sampling. The frame rates at the input and output are equal.

    • Allow multirate processing

      The unit generates an output signal at a lower (with a reduced sampling rate) speed, using a proportionally longer frame period on the output port than on the input port. When the sampling rate is lowered in times the period of the output frame in times longer than the period of the input frame ( ), but the sizes of the input and output frames are equal.

      For more information, 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

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

Dependencies

This parameter is not used if for the parameter Input processing the value is set Columns as channels (frame based), and for the parameter Rate options the value is set Enforce single-rate processing.

Default value

0

Program usage name

InitialCondition

Tunable

No

Evaluatable

Yes

More detailed

Frame-based processing

Details

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

In this mode, the unit can perform either single-speed or multi-speed processing. You can use the parameter Rate options to indicate how the block adjusts the output speed to accommodate the reduced number of samples.

  • When you set for the parameter Rate options meaning Enforce single-rate processing The block generates output data at a slower rate (with a reduced sampling rate) using a proportionally smaller frame size than the input.

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

  • When you set for the parameter Rate options meaning Allow multirate processing, block input and output Downsample they have the same size, but the sampling rate of the output is in times slower than at the entrance. In this mode, the block processes the matrix input. on how independent channels.

    In this mode, the unit receives only fixed-size signals, and these signals can have an arbitrary frame length.

Sample-based processing

Details

When you set for the parameter Input processing meaning Elements as channels (sample based), the block processes the input matrix on how independent channels and resamples each channel over time. The sampling period of the output signal ( ) in times longer than the sampling period of the input signal ( ), and the dimensions of the entrance and exit are identical.

In this mode, the unit receives only fixed-size signals, and these signals can have an arbitrary frame length.

Delay

Details

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

Block Downsample it has zero latency in the following cases:

  • The downsampling factor is equal to 1.

  • Parameter Input processing installed on Columns as channels (frame based), and the parameter Rate options installed on Enforce single-rate processing.

  • Parameter Input processing installed on Columns as channels (frame based), parameter Rate options installed on Allow multirate processing, parameter Sample offset (0 to M−1), , has the value 0, and the input frame size is 1.

  • Parameter Input processing installed on Elements as channels (sample based), and the parameter Sample offset (0 to M−1), , has the value 0.

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

In all other cases, the delay is not zero.:

  • When the parameter Input processing installed on Elements as channels (sample based), the delay is one sample.

  • When Input processing installed on Columns as channels (frame based) and the input frame size is more than one, the delay is one frame.

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

In all cases, the delay is one frame. The rows of the initial condition matrix appear sequentially as the first output lines. Input sample (line input matrix) appears in the output as a sample , followed by an input sample , input sample etc. Parameter Initial condition it can be a matrix of size on containing one value for each channel or a scalar that must be repeated for all elements of the matrix on .