MATLAB Answers

Dimitri
0

Every combination of elements

Asked by Dimitri
on 22 Jul 2019
Latest activity Answered by Fangjun Jiang on 22 Jul 2019
Hello,
I need to create every combination of the elements in a vector. For example I have the vector a=[2,3,1]. I need to split this vector into (1,2), (1,3), (2,3). Or if I have [1,2,3,4] I need to get (1,2) (1,3) (1,4) (2,3) (2,4) and (3,4). Is there a command for this kind of problem?

  0 Comments

Sign in to comment.

Tags

Products

1 Answer

Answer by Fangjun Jiang on 22 Jul 2019
 Accepted Answer

nchoosek(1:4,2)

  0 Comments

Sign in to comment.