Every combination of elements

1 回表示 (過去 30 日間)
Dimitri
Dimitri 2019 年 7 月 22 日
回答済み: Fangjun Jiang 2019 年 7 月 22 日
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?

採用された回答

Fangjun Jiang
Fangjun Jiang 2019 年 7 月 22 日
nchoosek(1:4,2)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by