DSP Blockset | ![]() ![]() |
Switch between two inputs after a specified number of sample periods.
Library
Signal Management / Switches and Counters
Description
The N-Sample Switch block outputs the signal connected to the top input port during the first N sample times after the simulation begins or the block is reset, where N is specified by the Switch count value. Beginning with output sample N+1, the block outputs the signal connected to the bottom input until the next reset event or the end of the simulation.
The sample period of the output is specified by the Sample time parameter (i.e., the output sample period is not inherited from the sample period of either input). The block applies a zero-order hold at the input ports, so the value the block reads from a given port between input sample times is the value of the most recent input to that port.
Both inputs must have the same dimension, except in the following two cases:
The inputs must either both be frame-based or both be sample-based.
The Reset input check box enables the Rst
input port. At any time during the count, a trigger event at the Rst
port resets the counter to zero. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input.
The triggering event is specified by the Trigger type pop-up menu, and can be one of the following:
Rst
input does one of the following:
Rst
input does one of the following:
Rst
input is a Rising edge or Falling edge (as described above).
Rst
input is not zero.
Note When running simulations in the Simulink MultiTasking mode, sample-based reset signals have a one-sample latency, and frame-based reset signals have one frame of latency. Thus, there is a one-sample or one-frame delay between the time the block detects a reset event, and when it applies the reset. For more information on latency and the Simulink tasking modes, see Excess Algorithmic Delay (Tasking Latency) and the topic on the Simulation Parameters dialog box in the Simulink documentation. |
Dialog Box
Rst
input port when selected. The rate of the reset signal must be a positive integer multiple of the rate of the data signal input.Rst
port that resets the block's counter. This parameter is enabled when Reset input is selected. Tunable.Supported Data Types
Rst
port, which is enabled when you set the Reset input parameter.
To learn how to convert to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.
See Also
Counter |
DSP Blockset |
N-Sample Enable |
DSP Blockset |
Also see Switches and Counters for a list of all the blocks in the Switches and Counters library.
![]() | N-Sample Enable | Normalization | ![]() |