logspace - Generate logarithmically spaced vector - MATLAB (original) (raw)

Generate logarithmically spaced vector

Syntax

Description

y = logspace([a](#f89-998709-a),[b](#f89-998709-b)) generates a row vector y of 50 logarithmically spaced points between decades 10^a and 10^b. The logspace function is especially useful for creating frequency vectors. The function is the logarithmic equivalent of linspace and the ‘:’ operator.

example

y = logspace([a](#f89-998709-a),[b](#f89-998709-b),[n](#f89-998709-n)) generates n points between decades 10^a and 10^b.

example

y = logspace([a](#f89-998709-a),pi) generates 50 points between10^a and pi, which is useful in digital signal processing for creating logarithmically spaced frequencies in the interval[10^a,pi].

y = logspace([a](#f89-998709-a),pi,[n](#f89-998709-n)) generates n points between 10^a andpi.

Examples

collapse all

Vector of Logarithmically Spaced Numbers

Create a vector of 50 logarithmically spaced points in the interval [10^1,10^5].

Vector with Specified Number of Values

Create a vector of 7 logarithmically spaced points in the interval [10^1,10^5].

y1 = 1×7 105 ×

0.0001    0.0005    0.0022    0.0100    0.0464    0.2154    1.0000

Vector of Logarithmically Spaced Complex Numbers

Create a vector of complex numbers with 8 logarithmically spaced points between 10^(1+2i) and 10^(5+5i).

y = logspace(1+2i,5+5i,8)

y = 1×8 complex 104 ×

-0.0001 - 0.0010i 0.0029 - 0.0024i 0.0133 + 0.0040i 0.0147 + 0.0497i -0.1242 + 0.1479i -0.7150 - 0.0822i -1.2137 - 2.3924i 4.9458 - 8.6913i

Input Arguments

collapse all

a — First bound

numeric scalar

First bound, specified as a numeric scalar. The a argument defines a bound of the interval over which logspace generates points. a can be real or complex, and the other bound, b, can be either larger or smaller than a. If b is smaller than a, then the vector contains descending values.

Data Types: single | double
Complex Number Support: Yes

b — Second bound

numeric scalar

Second bound, specified as a numeric scalar. The b argument defines a bound of the interval over which logspace generates points. b can be real or complex, and b can be either larger or smaller than the other bound, a. If b is smaller than a, then the vector contains descending values.

Data Types: single | double
Complex Number Support: Yes

n — Number of points

50 (default) | real numeric scalar

Number of points, specified as a real numeric scalar.

Extended Capabilities

C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

Thread-Based Environment

Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.

GPU Arrays

Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

The logspace function supports GPU array input with these usage notes and limitations:

For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Distributed Arrays

Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.

Usage notes and limitations:

For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).

Version History

Introduced before R2006a