random numbers can be divided b
조회 수: 1 (최근 30일)
이전 댓글 표시
hello,
how can i generate random numbers within a range that all generated numbers can be divided by 5??
meaning:
random number = r
r%5 = 0
regards
댓글 수: 0
채택된 답변
Star Strider
2019년 6월 15일
Try this:
r5 = randi(10,1,20)*5; % Creates 20 Random Integers From 5 To 50, All Of Which Can Be Divided Evenly By 5
Test = rem(r5,5)
The ‘Test’ vector will have elements only equal to 0.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!