Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

perms

Enumeration of 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. The matrix P contains n! rows and n columns.

perms is only practical when n is less than about 11 (for n = 11, the output takes over 3 gigabytes).

Examples

perms([2 4 6])

ans =

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

See Also

combnk

Introduced before R2006a

Was this topic helpful?