Documentation>MATLAB API>MISC - vl_colsubset

Y = VL_COLSUBSET(X, N) returns a random subset Y of N columns of X. The selection is order-preserving and without replacement. If N is larger or equal to the number of columns of X (e.g. N = Inf), then the function returns all the columns (i.e., Y = X).

If 0 < N < 1, then the function returns a fraction N of the columns (rounded to the closest integer).

[Y, SEL] = VL_COLSUBSET(...) returns the indexes SEL of the selected columns.

The function accepts the following options:


Returns the fist N columns.


Returns the last N columns.

Random [default]

Returns N columns selected at random (using RANDPERM()).


Returns N uniformly spaced columns.


Returns the N largest columns (using SORTROWS()).


Returns the N smallest columns (using SORTROWS()).