How to create a vector dVec = [5^0 5^0.01 ⋯ 5^0.99 5^1].
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I need to create a vector dVec = [5^0 5^0.01 ⋯ 5^0.99 5^1] (logarithmically spaced numbers between 1 and 10, use logspace), but I'm not sure I'm doing this correctly. So far, I've created this:
dVec = logspace(0, 1, 100)
How do I make sure it's 5's to the power of instead of 10's?
Thank you.
0 comentarios
Respuestas (3)
Image Analyst
el 20 de Jul. de 2016
Did you mean this:
exponents = 0 : 0.01 : 1
dVec = 5 .^ exponents
0 comentarios
Star Strider
el 20 de Jul. de 2016
The bsxfun function is your friend for these types of problems:
expvec = logspace(0, 1, 100);
dVec = bsxfun(@power, 5*ones(size(expvec)), expvec);
0 comentarios
Azzi Abdelmalek
el 20 de Jul. de 2016
Editada: Azzi Abdelmalek
el 20 de Jul. de 2016
ldVec = logspace(0, log10(5), 100)
0 comentarios
Ver también
Categorías
Más información sobre Operators and Elementary Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!