How to create non-repetitive random integers
34 次查看(过去 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!