Random number generator help

3 ビュー (過去 30 日間)
Kashish Pilyal
Kashish Pilyal 2022 年 5 月 31 日
回答済み: Voss 2022 年 5 月 31 日
I am looking to generate random numbers between a certain set of decimal numbers (for eg: 0.3 to 0.4). I tried using rand command but if anyone has a workaround?

採用された回答

Voss
Voss 2022 年 5 月 31 日
rand gives you number(s) between 0 and 1, so with appropriate scaling and offsetting, you can use it to get number(s) from any given range:
data = 0.3 + 0.1*rand(1,100) % 100 numbers between 0.3 and 0.4
data = 1×100
0.3596 0.3187 0.3503 0.3990 0.3179 0.3482 0.3384 0.3025 0.3906 0.3738 0.3543 0.3069 0.3705 0.3117 0.3616 0.3272 0.3565 0.3828 0.3806 0.3173 0.3632 0.3188 0.3767 0.3447 0.3255 0.3521 0.3875 0.3934 0.3428 0.3297
plot(data)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by