dsp.ZeroCrossingDetector System object

Package: dsp

Zero crossing detector


The ZeroCrossingDetector object counts the number of times the signal crosses zero, or changes sign. The zero crossing detector supports both floating-point and fixed-point data types.

To count the number of times a signal crosses zero or changes sign:

  1. Define and set up your zero crossing detector. See Construction.

  2. Call step to count the number of times according to the properties of dsp.ZeroCrossingDetector. The behavior of step is specific to each object in the toolbox.


H = dsp.ZeroCrossingDetector returns a zero crossing detector object, H, that counts the number of zero crossings in the real-valued,, floating-point, or fixed-point frame-based vector or matrix.


cloneCreate zero crossing detection object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
stepCount zero crossings in input


Find number of zero crossings in electrocardiogram data:

EcgData = ecg(500)';
Hzerocross = dsp.ZeroCrossingDetector;
NumZeroCross = step(Hzerocross,EcgData);  % Equal to 4
plot(1:500,EcgData,'b',[0 500],[0 0],'r','linewidth',2);


This object implements the algorithm, inputs, and outputs described on the Zero Crossing block reference page. The object properties correspond to the block parameters.

Was this topic helpful?