Skip to Main Content Skip to Search
Product Documentation

perms - All possible permutations

Syntax

P = perms(v)

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 4 6]) returns all the permutations of the numbers 2, 4, and 6:

     6     4     2
     6     2     4
     4     6     2
     4     2     6
     2     4     6
     2     6     4

Limitations

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

See Also

nchoosek | permute | randperm

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS