Qu

sweep

Builtin index · Plotting

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.

CodeInputOutputDescription
result = sweep(f0, f1, fs, n, [method=])
f0 numbernot documented yet
f1 numbernot documented yet
fs numbernot documented yet
n numbernot documented yet
method 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")
output
· plot: figure 64 (200 points)
· plot: figure 65 (200 points)
· plot: figure 66 (400 points)
-1.0 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1.0 0 50 100 150 200 250 300 350 400

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.