| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Signal Processing Blockset |
| Contents | Index |
| Learn more about Signal Processing Blockset |
Signal Operations
dspsigops

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:
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. 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.
The following example illustrates the behavior of the Zero Crossing block.
Create the following Simulink model.

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.
Use the Zero Crossing block to detect the number of zero crossing in each time step. Use the default parameters.
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)
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.

To run the model for two time steps, change the simulation Stop time to 1.
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.


| Port | Supported Data Types |
|---|---|
Input |
|
Cnt |
|
| Hit Crossing | Simulink |
![]() | Yule-Walker Method | Function Reference | ![]() |

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 |