logspace

Vector of logarithmically spaced points between two powers of ten.

Category: Language Fundamentals > Matrices and Arrays

Syntax

y = logspace(a, b)

50 points from 10^a to 10^b.

y = logspace(a, b, n)

n points from 10^a to 10^b.

Description

The ratio between consecutive points is constant, so the points look evenly spread on a log axis. Typical uses are frequency sweeps and parameter scans that cover many orders of magnitude, for example logspace(-3, 3, 7).

Note that the inputs are exponents, not the limits themselves: logspace(0, 2, 3) is 1 10 100.

Input arguments

a, b
Exponents of the first and last points.
n
Number of points (default 50).

Output arguments

y
Row vector whose logarithms are evenly spaced: 10.^linspace(a, b, n).

Example

logspace(0, 2, 3)
logspace(-1, 1, 4)
Output
ans = 1×3

     1    10   100
ans = 1×4

    0.1000    0.4642    2.1544   10.0000

Notes

The special case where b is pi (points between 10^a and pi) is not implemented; it is treated as an ordinary exponent.

See also

linspace semilogx loglog exp