필터 지우기
필터 지우기

Random number within a decimal range

조회 수: 4 (최근 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 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