Creating array from 1.e-20 to 1, with steps 1.e-19, 1.e-18..

5 ビュー (過去 30 日間)
Gina DiCarlo
Gina DiCarlo 2016 年 9 月 15 日
編集済み: John D'Errico 2016 年 9 月 15 日
The only command I know to control the steps is when you use the : operator, however the step is too small (0.e+01) and it gives me an error of a 1 by 0 matrix.
Not sure what to use here, I have tried linspace and logspace but none seem to be of help.
Thanks!

採用された回答

Peter Cook
Peter Cook 2016 年 9 月 15 日
logspace(-20,0,21)
  1 件のコメント
Gina DiCarlo
Gina DiCarlo 2016 年 9 月 15 日
Thank you! After looking at the help selection on logspace I had a serious face palm moment

サインインしてコメントする。

その他の回答 (1 件)

John D'Errico
John D'Errico 2016 年 9 月 15 日
編集済み: John D'Errico 2016 年 9 月 15 日
As Peter points out, logspace is the way to do this. (In fact, I up-voted his answer.) In general, use existing tools where you can. This minimizes the odds of any problems, makes your code easy to read and debug, etc. But you don't need to use it. For those who might want to see a simple alternative, this will suffice:
v = 10.^(-20:0);

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by