Randperm is not returning all numbers and is duplicating some
이전 댓글 표시
Essentially, I need to produce a list of numbers. The first 24 are the numbers 1 through 24, in a random order. The next 24 (numbers 25-48 of the big list) are also the numbers 1 through 24, in a different random order. This gets repeated 15 times.
I have set up code that initially seemed to work using a for loop and randperm. I repeatedly ask randperm to randomize the numbers 1 through 24 and I add those into my list. However, when examining the list more closely, the first few sets of 24 are fine, but then randperm breaks down a bit. In the third iteration of randperm, I get the number 21 repeated twice and I've lost the number 3. The next time through I have two 6's, but no 22.
Any guesses about why this might be happening? Are there constraints I can enter for randperm to ensure this doesn't happen?
Thanks!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!