Rank: 5707 based on 0 downloads (last 30 days) and 1 file submitted
photo

Michal

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Michal
Updated   File Tags Downloads
(last 30 days)
Comments Rating
28 Nov 2008 fpermute Derives a matrix of all possible permutations of natural numbers 1, 2, ... , N for a given N Author: Michal mathematics, statistics 0 1
  • 3.0
3.0 | 1 rating
Comments and Ratings on Michal's Files
Updated File Comment by Comments Rating
11 Dec 2008 fpermute Derives a matrix of all possible permutations of natural numbers 1, 2, ... , N for a given N Author: Michal Davis, Tim

A few suggestions. First and foremost, this code needs commenting. You have to look at the output matrix to figure out what matrix it's computing. This code has no comments at all. That's really the main reason I give it a rating of 3.

The second reason is that it needs to be redesigned. Wouldn't it make more sense to provide a function that returns each of the n! permutations one at a time? The matrix itself is huge. fpermute(10) returns a (10!)-by-10 matrix, about 3.6 million by 10. Surely an application doesn't need all 3.6 million permutations at the same time.

Something like:

k = 1
[p,k] = next_permutation(n,k)

which increments k. k=1 gives the first one (p=1:n), k=2 the next one, etc.

That would be a useful function. This one is limited by memory requirement to small values of n.

Top Tags Applied by Michal
mathematics, statistics
Files Tagged by Michal
Updated   File Tags Downloads
(last 30 days)
Comments Rating
28 Nov 2008 fpermute Derives a matrix of all possible permutations of natural numbers 1, 2, ... , N for a given N Author: Michal mathematics, statistics 0 1
  • 3.0
3.0 | 1 rating

Contact us at files@mathworks.com