How to create non-repetitive random integers

31 次查看(过去 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,

采纳的回答

Grzegorz Knor
Grzegorz Knor 2012-4-23
Try this code:
N = 100;
x = randperm(N);
x = x(1:70)

更多回答(2 个)

Richard Brown
Richard Brown 2012-4-23
randperm(100, 70)

Jan
Jan 2012-4-23
And if you are in a hurry: FEX: Shuffle

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by