randsample

randsample(n, k, nc) returns a k-by-nc vector containing values sampled uniformly at random, without replacement, of the set 1:n. The third argument is optional and its default values is 1.

Examples

>> rng(0) 

% for tractability

n = 10 x = randsample(n,2)# 8 6
>> rng(0)
x = randsample(n,5,2)#

            9            1
            7           10
            8            9
            5            3
            6            4

See also

rand | randi | randperm | rng