Hi everyone, I have a vector of 5 columns, x=[1 2 3 4 5]; i want to create all possible combinations of first element with the other remaining.

1 view (last 30 days)
Hi everyone, I have a vector of 5 columns, x=[1 2 3 4 5]; i want to create all possible combinations of first element with the other remaining and then all possible combinations of 2nd element with the other 4 and so on all the combinations of the remaining elements with the other remaining in the vector.

Accepted Answer

Walter Roberson
Walter Roberson on 11 Apr 2022
x = 1:5
x = 1×5
1 2 3 4 5
nchoosek(x, 2)
ans = 10×2
1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5
  4 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!