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
xl = linspace(0, 10, 60)
yl = 3 * xl + 1
r = learning_curve(knn_model, xl, yl, 1, seed = 11)
print("rows: {r.sizes}")
print("train R2: {round(r.train_mean, 4)}")
print("validation: {round(r.val_mean, 4)}")
output
rows: [10, 19, 29, 38, 48] train R2: [1, 1, 1, 1, 1] validation: [0.9394, 0.9832, 0.9917, 0.9936, 0.9949]
from statistics-ml
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