Find zero-crossings in a vector using a hysteretic detector.

[K,s,KK] = zero_crossings(x,TH,Tmax) % Matlab & Octave
list <- (x, TH, Tmax = NULL) # R

Find zero-crossings in a vector using a hysteretic detector. This is useful, e.g., to locate cyclic postural changes due to propulsion.

Input var Description Default value
x is a vector of data. This can be from any sensor and with any sampling rate. N/A
TH is the magnitude threshold for detecting a zero-crossing. A zero-crossing is only detected when values in x pass from -TH to +TH or vice versa. N/A
Tmax (optional) is the maximum duration in samples between threshold crossings. To be accepted as a zero-crossing, the signal must pass from below -TH to above TH, or vice versa, in no more than Tmax samples. This is useful to eliminate slow transitions. If Tmax is not given, there is no limit on the number of samples between threshold crossings. N/A
Output var Description Units
K is a vector of cues (in samples) to zero-crossings in x.N/A
s is a vector containing the sign of each zero-crossing (1 = positive-going, -1 = negative-going). s is the same size as K. If no zero-crossings are found K and s will be empty.N/A

Matlab & Octave

[K,s] = zero_crossings(sin(2*pi*0.033*(1:100)'),0.3)


list <- zero_crossings(sin(2 * pi * 0.033 * c(1:100)), 0.3)
list$K = c(15.143, 30.286, 45.429, 60.628, 75.771, 90.914)
list$s = c(-1, 1, -1, 1, -1, 1) Last modified: 19 July 2017

  • tagwiki/tools/processing/zero_crossings.txt
  • Last modified: 2017/07/27 18:57
  • by das39