RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • colon
    • createArray
    • empty
    • eye
    • false
    • full
    • inf
    • int16.empty
    • int32.empty
    • int64.empty
    • int8.empty
    • linspace
    • logspace
    • magic
    • meshgrid
    • nan
    • ndgrid
    • nonzeros
    • ones
    • peaks
    • rand
    • randi
    • randn
    • randperm
    • range
    • sparse
    • spdiags
    • speye
    • spones
    • sprand
    • true
    • uint16.empty
    • uint32.empty
    • uint64.empty
    • uint8.empty
    • zeros

logspace — Generate logarithmically spaced row vectors in MATLAB and RunMat.

logspace(a, b, n) returns a row vector of logarithmically spaced points from 10^a to 10^b. When b is exactly pi, the final value is pi. Real or complex single endpoints produce single output when either endpoint is single; otherwise output is double.

Syntax

x = logspace(start, stop)
x = logspace(start, stop, n)

Inputs

start
Type
NumericScalar
Required
Yes
Description
Starting exponent value.
stop
Type
NumericScalar
Required
Yes
Description
Ending exponent value.
n
Type
NumericScalar
Required
No
Default
50
Description
Number of points.
NameTypeRequiredDefaultDescription
startNumericScalarYes—Starting exponent value.
stopNumericScalarYes—Ending exponent value.
nNumericScalarNo50Number of points.

Returns

x
Type
NumericArray
Description
Row vector of logarithmically spaced values.
NameTypeDescription
xNumericArrayRow vector of logarithmically spaced values.

Errors

—
When
More than three input arguments are provided.
Message
logspace: expected two or three input arguments
—
When
The count argument is not a numeric scalar value.
Message
logspace: number of points must be a scalar
—
When
The count argument is NaN or infinite.
Message
logspace: number of points must be finite
IdentifierWhenMessage
—More than three input arguments are provided.logspace: expected two or three input arguments
—The count argument is not a numeric scalar value.logspace: number of points must be a scalar
—The count argument is NaN or infinite.logspace: number of points must be finite
—The count argument exceeds platform limits.logspace: number of points is too large for this platform
RunMat:gpu:ProviderOwnershipMismatchResident scalar inputs do not have one exact owning provider.logspace: GPU scalar inputs must have the same owning provider
RunMat:logspace:GpuUploadFailedAn explicitly resident result cannot be restored to its source provider.logspace: failed to preserve explicit gpuArray residency

Behavior

logspace(a, b) is equivalent to logspace(a, b, 50).

logspace(a, b, 0) returns a 1 × 0 empty row vector whose precision follows the endpoints.

logspace(a, b, 1) returns the effective final endpoint: 10^b, or pi when b is exactly pi.

logspace(a, b, 2) returns both effective endpoints.

Endpoints may be real or complex scalars. Complex inputs produce complex outputs using the analytic definition 10^z = e^{z ln 10}.

Endpoints must be real or complex single or double scalars. Integer and logical endpoints are rejected.

Scalar inputs may be numeric literals, 1×1 tensors, or GPU scalars. Non-scalar inputs raise an error.

The third argument must be a finite real numeric scalar. Fractional values are floored, and zero or negative values produce a 1 × 0 row vector.

Execution and residency

GPU endpoints establish an exact device owner, and endpoints from different owners are rejected. Explicitly resident endpoints force the result back to that owner when fallback is needed. Automatically resident inputs may fall back to a host result. Large host-generated sequences may be automatically placed on the active provider when the offload threshold is met.

For real sequences, providers can compose logspace from linspace, scalar multiplication, and unary_exp. Complex sequences are computed on the host and uploaded to the endpoint owner when supported; explicit residency requires that restoration to succeed. Device results are validated for exact ownership, shape, precision, storage kind, and aliasing before use.

Examples

Creating decades between 10 and 1000

x = logspace(1, 3, 3)

Expected output:

x = [10 100 1000]

Generating logarithmic spacing with the default 50 points

f = logspace(1, 4)

Expected output:

% f is a 1x50 row vector spanning [10, 10^4]
disp(f(1));
disp(f(end))

Requesting a single logarithmic sample

edge = logspace(-3, 2, 1)

Expected output:

edge = 100

Building a swept frequency vector on the GPU

lo = gpuArray(0);
hi = gpuArray(3);
freq = logspace(lo, hi, 256);
resp = sin(2*pi*freq)

Expected output:

% freq and resp remain on the GPU when an acceleration provider is active.
disp(gather(freq(1:5)))

Producing complex logarithmic spacing

z = logspace(1+1i, 2+2i, 4)

Expected output:

% Complex row vector with magnitudes and phases progressing logarithmically
disp(z)

Matching MATLAB's legacy logspace(a, pi, n) syntax

theta = logspace(-1, pi, 5)

Expected output:

% Interprets pi literally: theta(end) == pi
disp(theta(end))

Using logspace with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how logspace changes the result.

Run a small logspace example, explain the result, then change one input and compare the output.

FAQ

What base does logspace use?⌄

RunMat follows MATLAB and always computes powers of ten. To use another base, build your own sequence (base .^ linspace(...)) or multiply the output by a constant factor.

Does logspace include both endpoints?⌄

Yes. The first element is exactly 10^a. The final element is exactly 10^b, except for the special b == pi form, whose final element is exactly pi.

Can I request zero points?⌄

Yes. logspace(a, b, 0) returns a 1 × 0 empty row vector.

What happens when a equals b?⌄

Every element equals 10^a. For example, logspace(2, 2, 4) returns [100 100 100 100].

Does logspace support complex endpoints?⌄

Yes. Real and imaginary components are interpolated independently, and the final values are computed using 10^z = e^{z ln 10}.

Is the third argument required to be an integer?⌄

No. Finite fractional counts are floored. Zero and negative counts return an empty 1 × 0 row vector.

Does the function support GPU scalars?⌄

Yes. Endpoint scalars are read without discarding their owner or explicit-residency provenance. Supported sequences are generated on that owner; explicit fallback restores the result to the same owner.

How accurate is the last element?⌄

The implementation explicitly overwrites the final element with the effective endpoint—10^b, or pi for the exact b == pi form—to avoid floating-point drift.

How does logspace differ from linspace?⌄

linspace spaces points linearly between two values, whereas logspace spaces points logarithmically between powers of ten.

Can I generate descending values?⌄

Yes. logspace(3, 1, 4) returns [1000 464.1589 215.4435 100], decreasing logarithmically.

Related Array functions

Creation

colon · createArray · empty · eye · false · full · inf · int16.empty · int32.empty · int64.empty · int8.empty · linspace · magic · meshgrid · nan · ndgrid · nonzeros · ones · peaks · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · uint16.empty · uint32.empty · uint64.empty · uint8.empty · zeros

Accumulation

accumarray

Sorting Sets

argsort · intersect · ismember · ismembertol · issorted · issortedrows · setdiff · setxor · sort · sortrows · union · unique

Shape

blkdiag · cat · circshift · diag · flip · fliplr · flipud · horzcat · ipermute · kron · permute · repelem · repmat · reshape · rot90 · shiftdim · squeeze · toeplitz · tril · triu · vertcat

Combinatorics

combinations · nchoosek · perms

Binning

discretize

Indexing

find · ind2sub · sub2ind

Grouping

findgroups · groupcounts · grp2idx · splitapply

Introspection

height · iscolumn · isempty · ismatrix · isrow · isscalar · isvector · length · ndims · numel · size · width

Source you can read

Every RunMat function's source is public. Read exactly how logspace is executed, line by line, in Rust.

  • View the source for logspace in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Behavior
  • Execution and residency
  • Examples
  • Creating decades between 10 and 1000
  • Generating logarithmic spacing with the default 50 points
  • Requesting a single logarithmic sample
  • Building a swept frequency vector on the GPU
  • Producing complex logarithmic spacing
  • Matching MATLAB's legacy logspace(a, pi, n) syntax
  • Using logspace with coding agents
  • FAQ
  • Related Array functions
  • Creation
  • Accumulation
  • Sorting Sets
  • Shape
  • Combinatorics
  • Binning
  • Indexing
  • Grouping
  • Introspection
  • Source you can read
  • About RunMat