Generate list of frequencies evenly spaced in logarithmic plot

12 ビュー (過去 30 日間)
Michael
Michael 2024 年 3 月 18 日
編集済み: Stephen23 2024 年 3 月 18 日
For an experiment, I need to generate a list of frequencies (ranging from 0.2 rad/s to 628 rad/s). However, they need to be evenly spaced on a logarithmic scale. I have looked at logspace (https://www.mathworks.com/help/matlab/ref/logspace.html), but that does not quite seem to do what I need.
I struggle to understand how to approach the problem.
Thanks!

採用された回答

Stephen23
Stephen23 2024 年 3 月 18 日
X = logspace(log10(0.2),log10(628),8)
X = 1×8
0.2000 0.6318 1.9960 6.3054 19.9194 62.9270 198.7917 628.0000
Y = sqrt(X);
semilogx(X,Y,'-*')
  2 件のコメント
Michael
Michael 2024 年 3 月 18 日
Thank you!
Stephen23
Stephen23 2024 年 3 月 18 日
編集済み: Stephen23 2024 年 3 月 18 日
Another approach using LINSPACE (which is basically all that LOGSPACE does):
X = 10.^linspace(log10(0.2),log10(628),8)
X = 1×8
0.2000 0.6318 1.9960 6.3054 19.9194 62.9270 198.7917 628.0000

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

その他の回答 (1 件)

VBBV
VBBV 2024 年 3 月 18 日
F = linspace(0.2,628,100)
F = 1×100
0.2000 6.5414 12.8828 19.2242 25.5657 31.9071 38.2485 44.5899 50.9313 57.2727 63.6141 69.9556 76.2970 82.6384 88.9798 95.3212 101.6626 108.0040 114.3455 120.6869 127.0283 133.3697 139.7111 146.0525 152.3939 158.7354 165.0768 171.4182 177.7596 184.1010
semilogy(F)
  2 件のコメント
VBBV
VBBV 2024 年 3 月 18 日
use semilogy function for log scale but use linspace for evenly spaced values
Michael
Michael 2024 年 3 月 18 日
I see, thanks!

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by