linspace
Builtin index · Signal processing
result = linspace([a=0], [b=1], [n=50])
Input: a, b, n · Output: result
What it is
a, b (optional numbers): the inclusive endpoints; n (optional number, integer count).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = linspace([a=0], [b=1], [n=50]) | a number, optional (default 0)a, b (optional numbers): the inclusive endpoints.b number, optional (default 1)a, b (optional numbers): the inclusive endpoints.n number, optional (default 50)n (optional number, integer count). | result vector | Returns a length-n real vector, n linearly spaced points from a to b inclusive — the standard companion for building a time or frequency axis to plot alongside a generated/transformed signal. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
t = linspace(0, 1, 50)
plot(t, sin(t), label = "sin(x)")
legend top left
output
· plot: figure 5 (50 points)
from plotting
t = linspace(0, 1, 50)
plot(t, sin(t))
grid off
output
· plot: figure 6 (50 points)
from plotting
x = linspace(0, 1, 12)
a = randn(3, 4, seed = 6)
b = randn(3, 4, seed = 7)
v = [1, 2, 3, 4, 5, 6]
n = 4
r = 3
c = 4
df = table(price = [10.0, 12.5, 9.75, 14.0], volume = [100, 80, 140, 60])
from core-math
t = linspace(0, 1, 50)
plot(t, sin(t))
grid off
grid() # no-op -- gridlines stay off, not re-enabled
output
· plot: figure 7 (50 points)
from plotting