Generating random integer from -x to x
조회 수: 3 (최근 30일)
이전 댓글 표시
I need to find a way to generate a random integer from -x to x for example -5 to 5
댓글 수: 0
채택된 답변
추가 답변 (1개)
per isakson
2014년 3월 12일
편집: per isakson
2014년 3월 12일
2*x*rand-x produces uniformly distributed numbers
Doc says: Example 1, Generate values from the uniform distribution on the interval [a, b]:
r = a + (b-a).*rand(100,1);
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!