signal
result = signal(x, fs)
Input: x, fs · Output: result
What it is
Tags Vec x (numbers) with sample rate fs (number, Hz), so later calls (like rfft) do not have to be told it again.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = signal(x, fs) | x Vec or numbernot documented yetfs Vec or numbernot documented yet | result Signal | Returns a Signal. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
sig = signal([1, 5, 2, 8], 100)
print(threshold(sig, 4)) # signal(Fs=100) [0, 1, 0, 1]
output
signal(Fs=100) [0, 1, 0, 1]
from images
double(v) := v * 2
sig = signal([1, 2, 3, 4], 8)
s = sig.apply("double")
print("signal: {s}") # signal: signal(Fs=8) [2, 4, 6, 8]
output
signal: signal(Fs=8) [2, 4, 6, 8]
from signal-processing
double(v) := v * 2
sig = signal([1, 2, 3, 4], 8)
out = sig.apply("double") # same Fs, genuinely transformed
print("apply(double): {out}")
output
apply(double): signal(Fs=8) [2, 4, 6, 8]
from signal-processing
s = signal(0 to 9, 10) # 10 samples at 10 Hz, t = 0.0, 0.1, ..., 0.9s
trimmed = cut(s, 0.5, 100.0) # end clamps past the signal's duration
print("trimmed: {trimmed}")
@s.cut(0.2, 0.7) # self-mutating form: s = cut(s, 0.2, 0.7)
print("s after @cut: {s}")
output
trimmed: signal(Fs=10) [5, 6, 7, 8, 9] s after @cut: signal(Fs=10) [2, 3, 4, 5, 6, 7]
from signal-processing
How it works
§41.2 sampled-signal constructor/destructor. signal(data, Fs) (canonical spelling) and Signal(data, Fs) (capitalized alias) both work; array(x)/Array(x) unwraps back to a plain vector (a no-op on anything that already is one).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.