Downsample
Resample input at lower rate by deleting samples
- Library:
DSP System Toolbox / Signal Operations
DSP System Toolbox HDL Support / Signal Operations
Description
The Downsample block decreases the sampling rate of the input by deleting samples. When the block performs frame-based processing, it resamples the data in each column of the Mi-by-N input matrix independently. When the block performs sample-based processing, it treats each element of the input as a separate channel and resamples each channel of the input array across time. The resample rate is K times lower than the input sample rate, where K is the value of the Downsample factor parameter. The Downsample block resamples the input by discarding K–1 consecutive samples following each sample that is output.
This block supports triggered subsystems when you set the Rate
options parameter to Enforce single-rate
processing
.
Ports
Input
Port_1
— Data input
column vector | matrix | N-D array
Data input whose sampling rate is to be decreased by the block, specified as a column vector or a matrix.
When you set the Input processing parameter to
Elements as channels (sample based)
, the
input can be an N-D array.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
Complex Number Support: Yes
Output
Port_1
— Downsampled output
column vector | matrix
Downsampled output with a sampling rate that is 1/K times the input sampling rate, returned as a column vector or a matrix.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| fixed point
Complex Number Support: Yes
Parameters
Downsample factor, K
— Downsampling factor
2
(default) | positive integer
The integer factor, K, by which to decrease the input sample rate.
Sample offset (0 to K-1)
— Sample offset
0
(default) | integer
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 four phases.
Input Sequence | Sample Offset, D | Output Sequence (K = 4) |
---|---|---|
| 0 |
|
| 1 |
|
| 2 |
|
| 3 |
|
The initial zero in each of the latter three output sequences in the table is a result of the default zero Initial conditions parameter setting for this example. See Latency for more information on the Initial conditions parameter.
Input processing
— Method to process input
Columns as channels (frame
based)
(default) | Elements as channels (sample based)
Specify the method for input processing:
Columns as channels (frame based)
–– When you set the Input processing parameter toColumns as channels (frame based)
, the block treats each of the N input columns as an individual channel containing Mi sequential time samples. The block downsamples each channel independently by discarding K–1 rows of the input matrix following each row that it outputs.For more information, see What Is Frame-Based Processing?.
Elements as channels (sample based)
–– When you set the Input processing parameter toElements as channels (sample based)
, the input can be an N-D array. The Downsample block treats each element of the input as a separate channel, and resamples each channel of the input over 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.For more information, see What Is Sample-Based Processing?.
Rate options
— Enforce single-rate or allow multirate processing
Enforce single-rate
processing
(default) | Allow multirate processing
Specify the method by which the block adjusts the rate at the output to
accommodate the reduced number of samples. . You can select one of the
following options. The behavior of these options depends on whether the
Input processing parameter is set to
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 sample rate to match the input sample rate (Tso = Tsi) by repeating every Kth input sample K times at the output. In this mode, the behavior of the block is similar to the operation of a Sample and Hold block with a repeating trigger event of period KTsi.
Allow multirate processing
The sample period of the output is K times longer than the input sample period (Tso = KTsi).
Columns as channels (frame based)
Enforce single rate processing
The block generates the output at the slower (downsampled) rate using a proportionally smaller frame size than the input. For downsampling by a factor of K, the output frame size is K times smaller than the input frame size (Mo = Mi/K), but the input and output frame rates are equal.
The ex_downsample_ref2 model shows a single-channel input with a frame size of 64 being downsampled by a factor of 4 to a frame size of 16. The input and output frame rates are identical.
Allow multirate processing
The block generates the output at the slower (downsampled) rate by using a proportionally longer frame period at the output port than at the input port. For downsampling by a factor of K, the output frame period is K times longer than the input frame period (Tfo = KTfi), but the input and output frame sizes are equal.
The ex_downsample_ref1 model 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.
Initial conditions
— Initial value
0
(default) | real scalar | array
The initial block value for cases of nonzero latency. You can specify a scalar or an array of the same size as the input.
Dependencies
This parameter appears only when you set the Rate
options parameter to Allow multirate
processing
.
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
More About
Latency
Latency is the delay, measured in samples or frames, between the input and the output of the block.
The Downsample block has zero-tasking latency in the following cases:
The Downsample factor parameter, K, is
1
.The Input processing parameter is set to
Columns as channels (frame based)
, and the Rate options parameter is set toEnforce single-rate processing
.The Input processing parameter is set to
Columns as channels (frame based)
, the Rate options parameter is set toAllow multirate processing
, the Sample offset parameter, D, is set to0
, and the input frame size is equal to 1.The Input processing parameter is set to
Elements as channels (sample based)
, and the Sample offset parameter, D, is0
.
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. When there is zero-tasking latency, the block ignores the value of the Initial conditions parameter.
In all other cases, the latency is nonzero:
When the Input processing parameter is set to
Elements as channels (sample based)
, the latency is one sample.When the Input processing parameter is set to
Columns as channels (frame based)
and the input frame size is greater than one, the latency is one frame.
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 conditions 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 (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 conditions 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.
Note
For more information on latency and the Simulink® tasking modes, see Excess Algorithmic Delay (Tasking Latency) and Time-Based Scheduling and Code Generation (Simulink Coder).
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Generated code relies on the memcpy
or
memset
function (string.h
) under certain
conditions.
HDL Code Generation
Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic.
It is good practice to follow the Downsample block with a unit delay. Doing so prevents the code generator from inserting an extra bypass register in the HDL code.
See also Multirate Model Requirements for HDL Code Generation (HDL Coder).
This block has a single, default HDL architecture.
ConstrainedOutputPipeline | Number of registers to place at
the outputs by moving existing delays within your design. Distributed
pipelining does not redistribute these registers. The default is
|
InputPipeline | Number of input pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|
OutputPipeline | Number of output pipeline stages
to insert in the generated code. Distributed pipelining and constrained
output pipelining can move these registers. The default is
|
This block supports code generation for complex signals.
Input processing set to
Columns as channels (frame based)
is not supported.For Input processing set to
Elements as channels (sample based)
, selectAllow multirate processing
. With this setting, if Sample offset is set to 0, Initial conditions has no effect on generated code.
Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.
Version History
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)