- 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 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
per isakson
am 9 Okt. 2017
Akzeptierte Antwort
Jan
am 9 Okt. 2017
Bearbeitet: Jan
am 9 Okt. 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 Kommentare
Jan
am 10 Okt. 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]
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!