How to generate k unique random numbers from 1 to n in matlab 2009
Afficher commentaires plus anciens
Hi, I knew randperm(n,k) works but this is after 2011. Can some one tell me if there is any efficient way to do it in matlab 2009.
Thanks
Réponse acceptée
Plus de réponses (2)
Zhang lu
le 27 Avr 2013
1 vote
a=randperm(n); b=a(1:k)
Jan
le 27 Avr 2013
0 votes
Not biased and faster than sorting a RAND vector: http://www.mathworks.com/matlabcentral/fileexchange/27076-shuffle
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!