Qu

find_trigger

Builtin index · Signal processing

result = find_trigger(x, level, [edge="rising"])

Input: x, level, edge · Output: result

What it is

x: a length-N real vector or Signal; level: a number, the trigger level — positional and required (defaulting it would let find_trigger(x) answer confidently about a level the caller never chose), though level= is accepted as a keyword too. edge (optional string): "rising" (default), "falling", or "both"; "rise"/"fall"/"up"/"down"/"positive"/"negative"/"any"/"either" are accepted spellings.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = find_trigger(x, level, [edge="rising"])
x vector or Signalx: a length-N real vector or Signal.
level numberlevel: a number, the trigger level — positional and required (defaulting it would let find_trigger(x) answer confidently about a level the caller never chose), though level= is accepted as a keyword too.
edge string, optional (default "rising")edge (optional string): "rising" (default), "falling", or "both".
result vector
Returns a vector of 0-indexed integer sample indices, one per crossing, each being the first sample of the new state — a rising crossing at i means x[i-1] < level <= x[i]. A transition involving a NaN is skipped rather than reported, so a dropout does not manufacture a pair of edges.

Examples

No documentation example calls this form yet. The Signal processing chapter is where one belongs.

How it works

find_trigger(x, level, [edge="rising"]) -- the sample indices at which x crosses level. edge is "rising" (default), "falling", or "both". This is the primitive the rest of the cluster is built on. level is positional and REQUIRED, deliberately: a trigger level is the entire content of the question being asked, and defaulting it (to the midpoint, say) would let find_trigger(x) return a confident answer about a level the caller never chose. The derived functions below, whose subject is the pulse train rather than the level, do default it.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.