Write a vector with (for example) 10^-5 kind of numbers

1 回表示 (過去 30 日間)
Marie-Andrée Dionne
Marie-Andrée Dionne 2020 年 9 月 12 日
Hi everybody!
I want to write that vector :
h = [10^-1 10^-2 10^-3 10^-4 10^-5 10^-6 10^-7 10^-8 10^-9 10^-10 10^-11 10^-12 10^-13 10^-14 10^-15 10^16 10^-17 10^18 10^-19 10^-20]
I know I can write it by hand (like I did), but is there a more condence way to do it? I know there's a technique to write a vector like this [x:y:z], where y is the step, but it doens't seem to be working with 10^.
Thank you!

採用された回答

madhan ravi
madhan ravi 2020 年 9 月 12 日
10.^ (-(1:20))

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 9 月 12 日
logspace(-1,-20,20)
logspace is specifically for 10^ .
madhan ravi's response is a good one and generalizes to other bases easily; sometimes logspace() fits the "mood" of the code better.
  1 件のコメント
Marie-Andrée Dionne
Marie-Andrée Dionne 2020 年 9 月 12 日
oh ok great thank you for the information!

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by