How to create non-repetitive random integers
15 ビュー (過去 30 日間)
古いコメントを表示
Hi,
As the title suggests I want to create non-repetitive random integers but don't know how to... say 70 integers ranging from 1 to 100. is there a straight way to do this?
thanks,
0 件のコメント
採用された回答
Grzegorz Knor
2012 年 4 月 23 日
Try this code:
N = 100;
x = randperm(N);
x = x(1:70)
2 件のコメント
Dmitry Kaplan
2021 年 8 月 10 日
Another possibility (perhaps a little faster)
[~,idx]=sort(rand(100,1));
idx(1:70)
その他の回答 (2 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!