logspace with a different base

As far as I understood y = logspace(a,b,n) works for logarithms of base 10. For example we can have:
format longG
y = logspace(-2,3,6)
y = 1x6
1.0e+00 * 0.01 0.1 1 10 100 1000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Is there a similar function or a simple way to perform the same calculation, but with a custom base B (for example a base B=3.5)?
I mean something like this:
a = -2;
b = 3;
n = 6;
B = 3.5;
y = ...?

 採用された回答

Sim
Sim 2024 年 6 月 20 日

1 投票

maybe I found it, but I am not sure:
a = -2;
b = 3;
n = 6;
B = 3.5;
y = B .^ linspace(a, b, n)
y = 1x6
0.0816 0.2857 1.0000 3.5000 12.2500 42.8750
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

6 件のコメント

DGM
DGM 2024 年 6 月 20 日
Looks good to me.
Sim
Sim 2024 年 6 月 20 日
Thanks a lot! This is reassuring :-)
John D'Errico
John D'Errico 2024 年 6 月 20 日
編集済み: John D'Errico 2024 年 6 月 20 日
Yes. That will generate the desired spacing, for your chosen base.
Sim
Sim 2024 年 6 月 20 日
Many thanks!! Great! :-)
Stephen23
Stephen23 2024 年 6 月 20 日
As an aside, LOGSPACE does exactly that inside, just with B=10.
Sim
Sim 2024 年 6 月 20 日
編集済み: Sim 2024 年 6 月 21 日
Ah, good to know! Thanks a lot @Stephen23 :-)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

Sim
2024 年 6 月 20 日

編集済み:

Sim
2024 年 6 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by