File Exchange

image thumbnail


version (1.6 KB) by Mauro
pick a random sample out of an array


Updated 11 Mar 2010

View License

To test al model, with real data it can be useful to pick a smaller sample out of a bigger dataset.

An other application could be to decide how small a random sample should be to see if the process is working property.

Cite As

Mauro (2020). samplepick (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)


jep, and it's faster ;-) ...

The function randperm is practically ready-made for this application. To draw a subset, s, of size m from a dataset, d, of size n, one can simply do

perm = randperm(n);
s = d(perm(1:m));


works now with randperm

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux