logarithmically spaced vector in a certain range
Show older comments
How to create a logarithmically spaced vector say from values 3 to 10? Thank you!
Accepted Answer
More Answers (2)
Nathan Porter
on 7 Apr 2017
Like Marco, I would suggest using logspace. For example,
logspace(1,3,10)
creates a vector of 10 logarithmically spaced values between 10^1 and 10^3. If you instead want the bounds to be determined by a value and not the exponent, I generally use the following:
logspace(log10(3),log10(10),10)
This will create a vector of 10 logarithmically spaced values between 3 and 10.
1 Comment
Johann Martinez
on 15 Mar 2021
Thank Nathan, but what if I have a, b values equals to 0, 0.97, for example?
I mean, the logspaced vector is full of NaN, because of the negative logarithm...
thanks in advance
Marco
on 3 Oct 2014
1 vote
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!