Detect zero crossings
The dsp.ZeroCrossingDetector
System
object™ counts the number of times the signal crosses zero, or changes sign. To detect
if a signal in a given channel crosses zero, the object looks for the following conditions,
where, xi-l is the current signal value and
xi-1 is the previous signal value:
xi < 0 and xi-1 > 0
xi > 0 and xi-1 < 0
For some positive integer L, xi < 0, xi-l = 0, and xi-L-1 > 0, where .
For some positive integer L, xi > 0, xi-l = 0, and xi-L-1 < 0, where .
For the first input value, xi-1 and xi-2 are zero.
To count the number of times a signal crosses zero or changes sign:
Create the dsp.ZeroCrossingDetector object.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects? (MATLAB)
zcd = dsp.ZeroCrossingDetector
returns a
zero crossing detection object that calculates the number of times the signal crosses
zero.zcd
= dsp.ZeroCrossingDetector
For versions earlier than R2016b, use the step
function to run the System object algorithm. The arguments to step
are the
object you created, followed by the arguments shown in this section.
For example, y = step(obj,x)
and y = obj(x)
perform equivalent operations.
zcdOut = zcd(input)
To use an object function, specify the
System
object as the first input argument. For
example, to release system resources of a System
object named obj
, use
this syntax:
release(obj)