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.
y = logspace([a](#f89-998709-a),[b](#f89-998709-b),[n](#f89-998709-n))
generates n
points between decades 10^a
and 10^b
.
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
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
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.
- If
n
is1
,logspace
returns10^b
. - If
n
is zero or negative,logspace
returns an empty row vector. - If
n
is not an integer,logspace
roundsn
down and returnsfloor(n)
points.
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:
- To run this function on a GPU and obtain a
gpuArray
output, use any of the following syntaxes:
y = gpuArray.logspace(a,b)
y = gpuArray.logspace(a,b,n)
y = gpuArray.logspace(a,pi)
y = gpuArray.logspace(a,pi,n) - Alternatively, you can specify
a
,b
, orpi
as agpuArray
.
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:
- Use
distributed.logspace
to call the distributed version oflogspace
.
For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006a