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.

2 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 11 Avr 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 commentaires

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by