how can I generate different vectors with the all the unique combinations of numbers inside a one vector?

조회 수: 1 (최근 30일)
Hi, If i have a vector a like:
a=[1 2 3 4]:
how can I generate different vectors with the all the unique combinations of the original numbers like:
r=[1 2 3]
r=[1 2 4]
r=[2 3 4]
r=[1 2]
r=[1 3]
r=[1 4]
r=[2 3]
r=[2 4]
r=[3 4]
r=[1]
r=[2]
r=[3]
r=[4]

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 3월 16일
편집: Andrei Bobrov 2016년 3월 16일
a=[1 2 3 4]
r = cell;
for ii = numel(a)-1:-1:1
r = [r;num2cell(nchoosek(a,ii),2)];
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by