Randperm is not returning all numbers and is duplicating some
Mostra commenti meno recenti
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!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Random Number Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!