how to random value?

1 次查看(过去 30 天)
Tia
Tia 2013-4-3
how to random value 2 until 3? example:
>> a=rand(1)
a =
0.8833
but i want the answer 2,3 or 2,5 or 2,6, or 3. thanks

回答(2 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-4-3
编辑:Azzi Abdelmalek 2013-4-3
  2 个评论
Tia
Tia 2013-4-3
it doesn't work. the answer still 1 commas until 3. i want the answer's between 2 to 3

请先登录,再进行评论。


Mahdi
Mahdi 2013-4-3
编辑:Mahdi 2013-4-3
Generate values from the uniform distribution on the interval [a, b].
r = 2 + (3-2).*rand(1);
or the general form
r=a+(b-a).*rand(n);

类别

Help CenterFile Exchange 中查找有关 Random Number Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by