Count number of times signal crosses zero in single time step
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 you set the Input processing parameter
Elements as channels (sample based),
the block treats each element of the input as a time-varying channel.
If you set the Input processing parameter to
as channels (frame based), the block treats each column
of the input as an independent channel.
To run the model for one time step, the Stop time is
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
To do so, open the Configuration Parameters dialog box by selecting Model
Configuration Parameters from the Simulation menu.
In the Solver pane, set Stop
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) —
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|