DSP Blockset | ![]() ![]() |
Detect threshold crossing of accumulated nonzero inputs.
Library
Signal Management / Switches and Counters
Description
The Event-Count Comparator block records the number of nonzero inputs to the Data
port during the period that the block is enabled by a high signal (the value 1
) at the interval (Int
) port. Both inputs must be scalars, and the Int
input must be sample-based.
When the number of accumulated nonzero inputs first equals the Event threshold setting, the block waits one additional sample interval, and then sets the output high (1
). The block holds the output high until recording is restarted by a low-to-high (0
-to-1
) transition at the Int
port.
If the input to the Data
port is frame-based, the output is frame-based; otherwise, the output is sample-based.
Example
In the model below, the Event-Count Comparator block (Event threshold = 3) detects two threshold crossings in the input to the Data
port, one at sample 4 and one at sample 12.
All inputs and outputs are multiplexed into the workspace variable yout
, whose contents are shown in the figure below. The two left columns in the illustration show the inputs to the Data
and Int
ports, the center column shows the state of the block's internal counter, and the right column shows the block's output.
Dialog Box
Supported Data Types
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 |
Edge Detector |
DSP Blockset |
Also see Switches and Counters for a list of all the blocks in the Switches and Counters library.
![]() | Edge Detector | Extract Diagonal | ![]() |