Count the number of times that a vector of values changes sign. |
||
Syntax |
N,I = ZeroCrossings(V) |
|
Argument |
Name |
Description |
V |
A vector of real values. |
|
Outputs |
Name |
Description |
N |
The number of crossings. |
|
I |
The indices just prior to crossings. |
|
Example |
Find the number of zero crossings for the vector [0, -1, -1, 2, 0, 2, -1]. |
|
Syntax |
|
|
N, I = ZeroCrossings([0, -1, -1, 2, 0, 2, -1]) |
||
Results |
|
|
N = 3 I = 3 4 6 |
||
Comments |
Crossings are not counted for first or last points of 0. A crossing is counted if the sequence contains a zero, even if there is no actual sign change. |