how can I generate different vectors with the all the unique combinations of numbers inside a one vector?
1 回表示 (過去 30 日間)
古いコメントを表示
German Preciat Gonzalez
2016 年 3 月 16 日
コメント済み: German Preciat Gonzalez
2016 年 3 月 16 日
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]
0 件のコメント
採用された回答
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!