how to random value?

조회 수: 6 (최근 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
Azzi Abdelmalek
Azzi Abdelmalek 2013년 4월 3일
Then use
a=rand+2

댓글을 달려면 로그인하십시오.


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에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by