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 CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by