最近MATLABを使っている.
ふと,以下のような対数の数列を使いたいなと思った.
1 2 3 ... 10 20 ... 100 200 ... 1000しかしながら,上述したような数列を作る関数が見当たらなかった.
function scale = logscale(start,stop)
% function scale = logscale(start,stop)
step = start;
add = start;
cnt=1;
while step <= stop
scale(cnt)=step;
cnt=cnt+1;
step=step+add;
if mod(step,add*10) == 0
add = add * 10;
end
end
使い方は