This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

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.

    Note:   Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


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


expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

Find number of zero crossings in electrocardiogram data.

EcgData = ecg(500)';
Hzerocross = dsp.ZeroCrossingDetector;
NumZeroCross = 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.

Introduced in R2012a

Was this topic helpful?