sweep
result = sweep(f0, f1, fs, n, [method=])
Input: f0, f1, fs, n, method · Output: result
What it is
Generates a linear (or, with method="logarithmic", log) frequency sweep from f0 to f1 (numbers, Hz) sampled at rate fs (number, Hz) for n (integer) samples. chirp is the exact same call under a second name — both share one implementation.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = sweep(f0, f1, fs, n, [method=]) | f0 numbernot documented yetf1 numbernot documented yetfs numbernot documented yetn numbernot documented yetmethod number, optionalnot documented yet | Signal Veca tagged Vec carrying its own sample rate | Returns a Signal (a tagged Vec carrying its own sample rate) of length n. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
tri = triangle(5, 500, 200)
plot(tri, label = "triangle")
figure()
saw = sawtooth(5, 500, 200)
plot(saw, label = "sawtooth")
figure()
s = sweep(10, 100, 500, 400)
plot(s, label = "sweep")
· plot: figure 64 (200 points) · plot: figure 65 (200 points) · plot: figure 66 (400 points)
from plotting
How it works
chirp(f0, f1, fs, n, [method=]) (alias sweep) — a frequency sweep from f0 to f1 over n samples, reaching f1 exactly at the last sample (t = (n-1)/fs), MATLAB's own chirp convention. method="linear" (default) or "logarithmic"; see chirp_wave's own doc comment for the exact analytic-phase formulas (not a naive per-sample frequency-then-numerically-integrate approximation, which would accumulate phase error over a long sweep).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.