Random number within a decimal range

3 ビュー (過去 30 日間)
Akif
Akif 2014 年 9 月 14 日
コメント済み: Image Analyst 2014 年 9 月 14 日
How do I create a random number within the range 0.95 to 0.99? Any help is appreciated. Thanks in advance.

採用された回答

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014 年 9 月 14 日
編集済み: Salaheddin Hosseinzadeh 2014 年 9 月 14 日
Hi Akif,
This is exactly a copy paste from MATLAB's help, so for further info type
doc rand
Your solution
r = a + (b-a).*rand(100,1);
Be aware, rand is generates evenly distributed random randi is the same but integer, But randn generates normally distributed random (gaussian distribution)
Good Luck!
  2 件のコメント
Akif
Akif 2014 年 9 月 14 日
Thanks
Image Analyst
Image Analyst 2014 年 9 月 14 日
And there's also a randi() that generates integers, though they're actually of class double, not an integer class, though they are rounded (no fraction).

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

その他の回答 (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