Actual zero or any-value crossing

Finds actual zero (or any other value) "actual" crossings
1,1K Downloads
Aktualisiert 5. Okt 2007

Lizenz anzeigen

CROSSINGS returns the crossings of a given value in a vector. Note that it does not return "occurrences" of that value, unless the value is actually crossed.

When there is a value-crossing but not occurrence of that value, the user can determine if they want the crossing to be assigned either
- to the previous element of the input vector (option 'pre'), or
- to the following element (option 'fol'), or
- to that element whose value is closer to the value whose crossings are sought (option 'dis'), or
- to a value calculated after interpolation between the two (preceding and following) elements (option 'int').

Occurrences of the value whose crossings are sought at the beginning or end of the input vector are ignored (since no
actual crossings occur).

Also consecutive occurrences of the value whose crossings are sought, are assigned to the last occurrence before the crossing (see last example).

EXAMPLES
1. Assume that VALUE=0, X(4)=-2 and X(5)=3. Then
- 'dis' will assign the 0-crossing to n=4,
- 'pre' will assign the 0-crossing to n=4,
- 'fol' will assign the 0-crossing to n=5 and
- 'int' will assign the 0-crossing to t=4.4.

2. Assume that the VALUE = 0.
- X = [1 -1 0 -1]: CROSSING will return the 0-crossing from 1 to -1.
- The sequence -1, 0, -1 is not considered a crossing (0 is only reached but not crossed).
- X = [-1 0 0 -1]: CROSSING will not return any 0-crossings (0 is only reached but not crossed).
- X = [1 0 0 -1] : CROSSING will return only one 0-crossing at element 3 (from 0 to -1).

Although the code is checked, please send any overlookings or bugs.

It should work also when using previous versions.

Zitieren als

Christos Saragiotis (2024). Actual zero or any-value crossing (https://www.mathworks.com/matlabcentral/fileexchange/16155-actual-zero-or-any-value-crossing), MATLAB Central File Exchange. Abgerufen .

Kompatibilität der MATLAB-Version
Erstellt mit R2007a
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Veröffentlicht Versionshinweise
1.0.0.0

The previous version worked only for row vectors. Thanks to the review by John Lintern, it now works for column vectors as well.