How to generate k unique random numbers from 1 to n in matlab 2009
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (2)
Zhang lu
il 27 Apr 2013
1 voto
a=randperm(n); b=a(1:k)
Jan
il 27 Apr 2013
0 voti
Not biased and faster than sorting a RAND vector: http://www.mathworks.com/matlabcentral/fileexchange/27076-shuffle
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!