Zero crossing detector
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
To count the number of times a signal crosses zero or changes sign:
Define and set up your zero crossing detector. See Construction.
step to count the number of
times according to the properties of
The behavior of
step is specific to each object in
Starting in R2016b, instead of using the
zcd = dsp.ZeroCrossingDetector returns
a zero crossing detector object,
zcd, that counts
the number of zero crossings in the real-valued,, floating-point,
or fixed-point frame-based vector or matrix.
|step||Count zero crossings in input|
|Common to All System Objects|
Create System object with same property values
Expected number of inputs to a System object
Expected number of outputs of a System object
Check locked states of a System object (logical)
Allow System object property value changes
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)'; zcd = dsp.ZeroCrossingDetector; numZeroCross = zcd(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.
Usage notes and limitations:
See System Objects in MATLAB Code Generation (MATLAB Coder).