MATLAB Function Reference
  Go to function:
    Search    Help Desk 
perms    Examples   See Also

All possible permutations

Syntax

Description

P = perms(v), where v is a row vector of length n, creates a matrix whose rows consist of all possible permutations of the n elements of v. Matrix P contains n! rows and n columns.

Examples

The command perms(2:2:6) returns all the permutations of the numbers 2, 4, and 6:

Limitations

This function is only practical for situations where n is less than about 15.

See Also

nchoosek    Binomial coefficient or all combinations

permute     Rearrange the dimensions of a multidimensional array

randperm    Random permutation



[ Previous | Help Desk | Next ]