How to generate k unique random numbers from 1 to n in matlab 2009
이전 댓글 표시
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
채택된 답변
추가 답변 (2개)
Zhang lu
2013년 4월 27일
1 개 추천
a=randperm(n); b=a(1:k)
Jan
2013년 4월 27일
0 개 추천
Not biased and faster than sorting a RAND vector: http://www.mathworks.com/matlabcentral/fileexchange/27076-shuffle
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!