Products & Services Solutions Academia Support User Community Company

Learn more about Signal Processing Blockset   

Zero Crossing - Count number of times signal crosses zero in single time step

Library

Signal Operations

dspsigops

Description

The Zero Crossing block concludes that a signal in a given channel has passed through zero if it meets any of the following criteria, where xi is the current signal value, xi-1 is the previous signal value, and so on:

For the first input value, xi-1 and xi-2 are zero. The block outputs the number of times the signal crosses zero in a single time step at the Cnt port.

The input to this block must be a real-valued fixed-point or floating-point signal. If the input is a sample-based vector or matrix, then each entry is treated as a time-varying channel. If the input is a frame-based row vector of length N, it is treated as N independent channels. If the input is a frame-based column vector, it is treated as a single channel.

Examples

The following example illustrates the behavior of the Zero Crossing block.

  1. Create the following Simulink model.

  2. Use the Signal From Workspace block to create a frame-based signal. Set the parameters as follows:

    • Signal = [-3:3]'

    • Sample time = 1/7

    • Samples per frame = 7

    • Form output after final data value by = Cyclic repetition

    The block outputs a single frame of the frame-based signal at the first time step, and identical frames at each additional time step.

  3. Use the Zero Crossing block to detect the number of zero crossing in each time step. Use the default parameters.

  4. Use the Display block to view the number of zero crossings.

  5. To run the model for one time step, set the configuration parameters. Open the Configuration Parameters dialog box by selecting Configuration Parameters from the Simulation menu. In the Solver pane, set the parameters as follows:

    • Stop time = 0

    • Type = Fixed-step

    • Solver = Discrete (no continuous states)

  6. Run the model.

    Because the signal passes through zero once during the first time step, the Zero Crossing block finds one zero crossing as shown in the figure below.

  7. To run the model for two time steps, change the simulation Stop time to 1.

  8. Run the model.

    The Zero Crossing block remembers that the last value of the last frame was 3. Therefore, the signal passes through zero twice during the second time step. It passes through zero while going from 3 to -3, and it passes through zero again while going from -3 to 3. The Zero Crossing block finds two zero crossings in the second time step as shown in the figure below.

Dialog Box

Supported Data Types

PortSupported Data Types

Input

  • Double-precision floating-point

  • Single-precision floating-point

  • Fixed point (signed and unsigned)

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Cnt

  • 32-bit unsigned integers

See Also

Hit CrossingSimulink

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS