Contents

dsp.ZeroCrossingDetector System object

Package: dsp

Zero crossing detector

Description

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.

Construction

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.

H = dsp.ZeroCrossingDetector('PropertyName',PropertyValue, ...) returns a zero crossing detector object, H, with each property set to the specified value.

Properties

FrameBasedProcessing

Enable frame-based processing

Set this property to true to enable frame-based processing. Set this property to false to enable sample-based processing. The default is true.

If the FrameBasedProcessing property is true:

  • The zero crossing detector treats a column vector or the columns of a matrix as single, independent channels.

  • The zero crossing detector treats a length N row vector as N independent channels.

If the FrameBasedProcessing property is false:

  • The zero crossing detector treats each entry of a vector or matrix as an independent channel.

Methods

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

Examples

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);

Algorithms

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

Both this object and its corresponding block let you specify whether to process inputs as individual samples or as frames of data. The object uses the FrameBasedProcessing property. The block uses the Input processing parameter. See Set the FrameBasedProcessing Property of a System object for more information.

Was this topic helpful?