FUNCTION REFERENCE
randsample
Random sample from integers or a population vector.
Random sample from integers or a population vector.
Syntax
y = randsample(n_or_population,k[,replacement[,weights]])Without replacement (default), uniform selection delegates to randperm(n,k) with memory proportional to k. With replacement, nonnegative weights select probabilities. Scalar n gives a double column of integers from 1 to n; population vectors preserve class and orientation. Numeric, logical, char and string populations are supported.
Example
rng(7); randsample(1e9,5)Differences from MATLAB: samples differ even after rng(seed); only rand, randn and randi match its stream. Cell populations and RandStream inputs are not supported yet.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.