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!