Documentation |
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 x_{i} is the current signal value, x_{i-1} is the previous signal value, and so on:
x_{i} < 0 and x_{i-1} > 0
x_{i} > 0 and x_{i-1} < 0
For some positive integer L, x_{i} < 0, x_{i-l} = 0, and x_{i-L-1} > 0, where $$0\le l\le L$$.
For some positive integer L, x_{i} > 0, x_{i-l} = 0, and x_{i-L-1} < 0, where $$0\le l\le L$$.
For the first input value, x_{i-1 } and x_{i-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 to 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 Columns as channels (frame based), the block treats each column of the input as an independent channel.
The following example, ex_zero_crossingex_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.
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.
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.
Note: The Inherited (this choice will be removed - see release notes) option will be removed in a future release. See Frame-Based Processing in the DSP System Toolbox™ Release Notes for more information. |