randsample
statistics: y = randsample (v, k)
statistics: y = randsample (v, k, replacement=false)
statistics: y = randsample (v, k, replacement=false, [w=[]])
Sample elements from a vector.
Returns k random elements from a vector v with n elements, sampled without or with replacement, with an optional weight vector.
If v is a non-negative integer scalar, samples from 1:v; it must
not be Inf. Any other scalar, -Inf and NaN included, is
a population of one element. k must be finite.
If a weight vector w of the same size as v is specified, the probability of each element being sampled is proportional to w. Unlike Matlab’s function of the same name, this can be done for sampling with or without replacement.
Randomization is performed using rand().
See also: datasample, randperm
Source Code: randsample