find_pulses
Builtin index · Signal processing
result = find_pulses(x, [level=], [hysteresis=0], [polarity="positive"])
Input: x, level, hysteresis, polarity · Output: result
What it is
x: a length-N real vector or Signal; level/hysteresis as for find_edges; polarity (optional string): "positive" (default) pairs each rising edge with the next falling one, "negative" the reverse.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = find_pulses(x, [level=], [hysteresis=0], [polarity="positive"]) | x vector or Signalx: a length-N real vector or Signal.level optionallevel/hysteresis as for find_edges.hysteresis optional (default 0)level/hysteresis as for find_edges.polarity string, optional (default "positive")polarity (optional string): "positive" (default) pairs each rising edge with the next falling one, "negative" the reverse. | Model —kind "pulses"stops vectorvectors of integer sample indices — stops, not ends, because end is a Qu keywordwidths vector or Signala vector of times: seconds for a Signal, samples otherwise, measured between the interpolated crossings so that mean(p.widths) equals pulse_width(x) exactlycount numbera number | Returns a Model (kind "pulses") with fields starts, stops (vectors of integer sample indices — stops, not ends, because end is a Qu keyword), widths (a vector of times: seconds for a Signal, samples otherwise, measured between the interpolated crossings so that mean(p.widths) equals pulse_width(x) exactly), and count (a number). A partial pulse at either end of the record — already high when capture started, or still high when it stopped — has only one of its two edges and is not reported; its width is genuinely unknown. |
Examples
No documentation example calls this form yet. The Signal processing chapter is where one belongs.
How it works
find_pulses(x, [level=], [hysteresis=], [polarity="positive"]) -- consecutive opposite-going edge pairs, as a Model with parallel fields starts, stops and widths, plus a scalar count. Field names are plural to match findpeaks's own peaks/locations/ prominences/widths convention; stops rather than the obvious ends because end is a Qu keyword and a field spelled that way would be awkward to reach. UNITS, because this record deliberately mixes them: starts/stops are integer sample INDICES (they index into x), while widths are TIMES -- seconds for a Signal, samples otherwise -- measured between the interpolated crossings. The alternative, widths in whole samples, would make mean(p.widths) disagree with pulse_width(x) on the same input, which is a worse trap than a documented mixed record. A partial pulse at either end of the record -- already high when capture started, or still high when it stopped -- has only one of its two edges and is NOT reported. Its width is genuinely unknown and a truncated one would look fine.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.