Created
October 27, 2011 12:17
-
-
Save avanwieringen/1319401 to your computer and use it in GitHub Desktop.
Combinations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ comb ] = combinations( set, length ) | |
comb = []; | |
for i=1:(size(set,2) - length + 1) | |
if(length > 1) | |
chcombs = combinations(set(i+1:end), length - 1); | |
for i_c=1:size(chcombs, 1) | |
comb(end + 1,:) = [set(i) chcombs(i_c,:)]; | |
end | |
else | |
comb(end + 1,:) = set(i); | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment