Main Content

Edge Detector

Detect transition from zero to nonzero value

  • Edge Detector block

Libraries:
DSP System Toolbox / Signal Management / Switches and Counters

Description

The Edge Detector block generates an impulse (the value 1) in a given output channel when the corresponding channel of the input transitions from zero to a nonzero value. When the input does not transition from zero to a nonzero value, the block generates a zero in the corresponding output channel.

This block supports only discrete-time fixed-step signals. Continuous signals are not supported.

The output has the same dimension and sample rate as the input. When you set the Input processing parameter to Columns as channels (frame based), the block counts an edge that is split across two consecutive frames in the frame that contains the nonzero value. For example, if there is a zero at the bottom of the first frame and a nonzero value at the top of the second frame, the block counts the edge in the second frame.

Examples

expand all

Detect edges in a signal using the Edge Detector block.

In the ex_edgedetector_ref model, the Input processing parameter of the Edge Detector block is set to Columns as channels (frame based). Thus, the block interprets the 3-by-2 input as a multichannel signal with a frame size of 3. The Matrix Concatenate block concatenates the two input channels of the original signal with the two output channels of the Edge Detector block to create the four-channel workspace variable sp_examples_yout.

As shown in the following figure, the block finds edges at sample 7 in channel 1, and at samples 2, 5, and 9 in channel 2.

Closing the model clears the "sp_examples_yout" variable from your workspace.

Extended Examples

Ports

Input

expand all

Specify the input signal as a vector or a matrix.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated

Output

expand all

The block returns the output of the edge detector as a vector or a matrix.

The block might output Boolean values depending on the input data type, and whether Boolean support is enabled or disabled.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated

Parameters

expand all

Specify how the block should process the input. You can set this parameter to one of the following options:

  • Columns as channels (frame based) (default) — When you select this option, the block treats each column of the input as a separate channel.

  • Elements as channels (sample based) — When you select this option, the block treats each element of the input as a separate channel.

Block Characteristics

Data Types

Boolean | double | fixed point | integer | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

Version History

Introduced before R2006a