File Exchange

image thumbnail

n permute k

version 1.1 (2.36 KB) by

Based on Matt Fig's npermutek this function returns all possible permutations of most matlab classes

4 Downloads

Updated

View License

Permutation of elements with replacement/repetition. MAT = npermutek(N,K) returns all possible samplings of length K from vector N of type: ordered sample with replacement. MAT has size (numel(N)^K)-by-K, where K must be a scalar. [MAT, IDX] = npermutek(N,K) also returns IDX such that MAT = N(IDX).
N may be of any numeric class, char, cell, struct, or even obj.

Comments and Ratings (2)

Can you help to get all unique combinations which dosn't include aa or bb or 1 1 1 1 or 2 2 2 2

Stephen Cobeldick

Finally a combinatorics submission that actually recognizes the difference between combinations and permutations!

Updates

1.1

Changed description
Cell example was wrong

MATLAB Release
MATLAB 8.0 (R2012b)
Acknowledgements

Inspired by: N_PERMUTE_K

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video