For e.g., if [1,2,3,4,5,6] is a vector, then all possible combinations of 3 items at a time is
4 5 6
3 5 6
3 4 6
3 4 5
2 5 6
2 4 6
2 4 5
2 3 6
2 3 5
2 3 4
1 5 6
1 4 6
1 4 5
1 3 6
1 3 5
1 3 4
1 2 6
1 2 5
1 2 4
1 2 3
How do I find this in MATLAB?
Try this link. Basically you just need to type
c = combnk(1:6,3). Hope it helps.Edit: The difference between what I proposed and @nash ‘s
combntnsis the toolbox that the commands are in.combnkis in the Statistics Toolbox, whilecombntnsis in the Mapping Toolbox.