Code covered by the BSD License  

Highlights from
nextperm

Be the first to rate this file! 2 Downloads (last 30 days) File Size: 1.27 KB File ID: #22692

nextperm

by Steven Gregory

 

15 Jan 2009 (Updated 12 Aug 2010)

Outputs the next permutation of the ordered tuple x.

| Watch this File

File Information
Description

Using lexical order on the set {1, 2, ..., N}, outputs the next permutation of the ordered tuple x. You have exhausted the list when All(nextperm(x,N) == x) is TRUE.

For example
   nextperm([1 5 4], 5) returns [2 1 3]
   nextperm([2 1 3], 5) returns [2 1 4]
   nextperm([5 4 3], 5) returns [5 4 3]

MATLAB release MATLAB 7.2 (R2006a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
13 Apr 2009 Steven Gregory

I don't know how to edit my own submission. The description should read "Using lexical order on the set {1, 2, ..., N}...".

13 Apr 2009 John D'Errico

As long as you are logged in, you are given the option to "update file" or "delete file". These are links right next to the "watch this file" link, near the top. When you update the file, you can change the description text to read as you wish.

Please login to add a comment or rating.
Updates
12 Aug 2010

Made a small change in the description of the function.

Tag Activity for this File
Tag Applied By Date/Time
permutation Steven Gregory 16 Jan 2009 14:42:40
permutation iterator Steven Gregory 16 Jan 2009 14:42:40
mathematics Steven Gregory 16 Jan 2009 14:42:40

Contact us at files@mathworks.com