Generating exhaustive permutations from specific inputs

2 views (last 30 days)
I need a code that will allow me to find all the possible permutations for a set of numbers (order IS important). The problem is the size of the dataset, which prevents me from using something simple like nchoosek. I have 3 inputs, A, B and C, and they can be arranged in any order to form an output that is 60 characters long - it can be all A, all B, all C and everything in between. Doing the maths I realised this wouldn't work (i think there would be over 10e104 permutations!) so i decided to narrow it down - I want an exhaustive list where the inputs are now AAAAA, BBBBB, CCCCC (so they come in blocks of 5) with a total of 60 characters in an output, or if you like 12 blocks of characters. If this is still too much for Matlab (~30million outputs?) then I can stretch so far as to go in blocks of 10 (AAAAAAAAAA etc) with 5 blocks of output (only 3000 outputs i believe?) Thank you in advance for any help offered!

Answers (1)

Jan
Jan on 24 Jul 2012
These Mex functions can be used to create the index matrices for permutations and combinations:
Because they operate e.g. on UINT32 input directlyand do not create intermediate DOUBLE arrays, they have a small memory footprint. Then these functions can be used to create the index vector, which represents your wanted output. It is (most likely) not necessary to create the strings explicitely. If you really want the data as 'AAAAA...', think of using uint8(1111...) instead, because an UINT8 used 1 byte, while the CHAR needs 2 bytes.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!