How to create array with unequal spacing?
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmad Hasnain
am 21 Feb. 2018
Kommentiert: Walter Roberson
am 22 Feb. 2018
I want to create an array with unequal spacing. I have h = 1 1/2 1/4 1/8 ..... 2^-60.
Every second entry in this array is 1/2 of the last one. I only know, how to make arrays with equal spacing.
a = 1:5:40
But how do I create array that gets halved with every entry?
5 Kommentare
Walter Roberson
am 22 Feb. 2018
In 2.^-(0:60) the JIT is detecting that the expression is constant and optimizes it, at least in the case of re-use. If you use B = 2; B.^-(0:60) or if you use V = -(0:60); 2.^B then JIT optimization is not as good and pow2 can have better performance than those.
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Performance and Memory 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!