- Homework?
- "I've tried so many different answers but nothing worked" Show us one or two of the most promising and we might to able to improve on them.
How do I create a sequence which goes from 1 to .000001?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
How do I create a sequence which will go from 1 to .000001 looking like this:
1.0 0.1 .01 .001 .0001 .00001 .000001
It seems simple and I've tried so many different answers but nothing worked. I tried
1:-.1:0, 1:-.01:0,
amongst many other ways turned out to be duds.
2 Commenti
per isakson
il 9 Ott 2017
Risposta accettata
Jan
il 9 Ott 2017
Modificato: Jan
il 9 Ott 2017
The power operator is expensive. It is more efficient to use
cumprod(repmat(0.1, 1, 6))
If this is a homework, I leave the last step up to you.
[EDITED] What about:
10 .^ (0:-1:-6)
4 Commenti
Jan
il 10 Ott 2017
but if you -1 the answer
It is a bold speculation that a 1 is subtracted from 10^0 here. Split the expression into parts, to understand it:
(0:-1:-6)
This part is included in parenthesis, such that it is evaluated at first. You have learned something about the colon operator already: "a:b:c" means: start at a and add b until c is reached. This works with a negative b also.
The second part is 10 .^ .... "^" is the power operation, and ".^" means, that it is applied elementwise. Without the dot it would be a matrix operation.
Finally you get:
10 .^ [0,-1,-2,-3,-4,-5,-6]
or equivalently:
[10^0, 10^-1, 10^-2, ... 10^-6]
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!