Random with no duplicate

Hello everyone, I’m trying to random some values in range 1:100, and i want every value is unique, not duplicate. I’m using rand(1:100, n) to random n values but it doesn’t work as expected. Anyone give me solution ? Thanks

Check this thread Sampling from a list of integers without repetition

2 Likes

Thanks, i solved it

mydata=unique(rand(1:100, n)) ?

1 Like

That will not in general return n numbers though.

2 Likes