フィルターのクリア

How can I generate a random real numbers from a specific range?

2 ビュー (過去 30 日間)
Abdulatif Alabdulatif
Abdulatif Alabdulatif 2014 年 9 月 13 日
編集済み: Image Analyst 2014 年 9 月 14 日
Hi all,
I want to pick real numbers randomly from a specific range (0 , 0.2304). Can any one help me to do that?
Thank you
  1 件のコメント
Image Analyst
Image Analyst 2014 年 9 月 13 日
Did you look up rand in the help? It's the very first example.

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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 9 月 13 日
編集済み: Azzi Abdelmalek 2014 年 9 月 13 日
rand*0.2304
For a general case (a,b)
a=0.12
b=0.45
out=a+(b-a)*rand;
  2 件のコメント
Abdulatif Alabdulatif
Abdulatif Alabdulatif 2014 年 9 月 14 日
Thanks for the answer. However, is there a way to reduce the generated number to 4 float point numbers?
for example:
0.187712337344988 --> 0.1877
Thanks again!
Image Analyst
Image Analyst 2014 年 9 月 14 日
編集済み: Image Analyst 2014 年 9 月 14 日
out4decimalPlaces = round(out * 10000)/10000
Please mark Azzi's answer as Accepted now.

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

その他の回答 (0 件)

カテゴリ

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