>> vec = 1:5;
>> fun = @(n)num2cell(combnk(vec,n),2);
>> out = arrayfun(fun,1:numel(vec),'uniformoutput',0);
>> out = vertcat(out{:});
>> out{:}
ans =
1
ans =
2
ans =
3
ans =
4
ans =
5
ans =
1 2
ans =
1 3
ans =
1 4
ans =
1 5
ans =
2 3
ans =
2 4
ans =
2 5
ans =
3 4
ans =
3 5
ans =
4 5
ans =
1 2 3
ans =
1 2 4
ans =
1 2 5
ans =
1 3 4
ans =
1 3 5
ans =
1 4 5
ans =
2 3 4
ans =
2 3 5
ans =
2 4 5
ans =
3 4 5
ans =
1 2 3 4
ans =
1 2 3 5
ans =
1 2 4 5
ans =
1 3 4 5
ans =
2 3 4 5
ans =
1 2 3 4 5
>>
Best Answer