My colleague walked into my office with a MATLAB question, a regular pasttime for us here at the MathWorks. He wanted to take every combination of one value from each of three distinct vectors. Now, this could be done easily with some nested for loops, but that really does violate the spirit in which such challenges are issued. I did not know of a function in MATLAB that did that, but I figured someone had invented that wheel before, so off to the File Exchange. A few minutes later I remembered the difference between combinations and permutations and had found two great new picks for this week.
Permutations: A great little file, with published documentation, that will find all permutations with lots of options.
Combinations: Another great little utility that answered my colleague’s challenge. It was nice to see that the author, Jos, followed up on comments from reviewers and made some good enhancements to the file.
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.