logspace

logspace(start, stop, n=50)

Construct a vector of n logarithmically spaced numbers from 10^start to 10^stop.

Examples

julia> logspace(1, 3, 5)
5-element Array{Float64,1}:
  10.0
  31.622776601683793
  100.0
  316.22776601683796
  1000.0
  1. Generate logarithmically spaced numbers:

    julia> logspace(0, 2, 4)
    4-element Array{Float64,1}:
    1.0
    10.0
    100.0
    1000.0

    This example generates an array of 4 logarithmically spaced numbers ranging from 10^0 to 10^2.

  2. Create a plot with logarithmic axis:

    using Plots
    
    # Generate logarithmically spaced numbers
    x = logspace(-2, 2, 100)
    
    # Create y-values using a function
    y = sin.(x)
    
    # Plot using logarithmic x-axis
    plot(x, y, xaxis=:log)

    In this example, logspace is used to generate logarithmically spaced x-values for a plot with a logarithmic x-axis.

  3. Specify the number of elements in the output:
    julia> logspace(1, 3, 3)
    3-element Array{Float64,1}:
    10.0
    100.0
    1000.0

    It generates an array with 3 logarithmically spaced numbers.

Common mistake example:

julia> logspace(3, 1, 5)
ERROR: DomainError with -3.0:
"start = 3 > stop = 1"

In this example, the start value is greater than the stop value, resulting in a DomainError. Ensure that the start value is less than the stop value when using logspace.

See Also

abs2, beta, binomial, ceil, cell, cross, ctranspose, ctranspose!, cummin, cumprod, cumprod!, cumsum, cumsum!, cumsum_kbn, div, divrem, eigfact, eigfact!, eigmin, eps, erf, erfc, erfcinv, erfcx, erfi, erfinv, exp, exp10, exp2, expm1, exponent, factor, factorial, factorize, floor, gcd, invmod, log, log10, log1p, log2, logspace, max, min, mod, mod1, modf, next, nextpow, nextprod, num, primes, primesmask, prod, realmin, sqrt, sum!, sumabs, sumabs!, sumabs2, sumabs2!,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: