Count number of times signal crosses zero in single time step
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 x_{i} is the current signal value, x_{i1} is the previous signal value, and so on:
x_{i} < 0 and x_{i1} > 0
x_{i} > 0 and x_{i1} < 0
For some positive integer L, x_{i} < 0, x_{il} = 0, and x_{iL1} > 0, where $$0\le l\le L$$.
For some positive integer L, x_{i} > 0, x_{il} = 0, and x_{iL1} < 0, where $$0\le l\le L$$.
For the first input value, x_{i1 } and x_{i2} 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 realvalued fixedpoint or
floatingpoint signal. If you set the Input processing parameter
to Elements as channels (sample based)
,
the block treats each element of the input as a timevarying channel.
If you set the Input processing parameter to Columns
as channels (frame based)
, the block treats each column
of the input as an independent channel.
The following example, ex_zero_crossing illustrates the behavior of the Zero Crossing block.
To run the model for one time step, the Stop time is
set to 0
.
Run the model.
Because the signal passes through zero once during the first time step, the Zero Crossing block finds one zero crossing. The number of detected zero crossings in the first time step is shown in the Display block in the following figure.
To run the model for two time steps, change
the simulation Stop time to 1
.
To do so, open the Configuration Parameters dialog box by selecting Model
Configuration Parameters from the Simulation menu.
In the Solver pane, set Stop
time to 1
.
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 Display block in the following figure.
Specify how the block should process the input. You can set this parameter to one of the following options:
Columns as channels (frame based)
(default)
— When you select this option, the block treats each column
of the input as a separate channel.
Elements as channels (sample based)
—
When you select this option, the block treats each element of the
input as a separate channel.
Port  Supported Data Types 

Input 

Cnt 

Hit Crossing  Simulink 