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

2 次查看(过去 30 天)
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

采纳的回答

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
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 CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by