All the posible combination of two matrices
조회 수: 6 (최근 30일)
이전 댓글 표시
I have two matrix
A=[1]
and
B=[2 3 4]
find the all possible combination of these tow matrices is
the output
C=[1 2; 1 3; 1 4; 1 2 3; 1 2 4; 1 3 4; 1 2 3 4]
how to find it
댓글 수: 0
채택된 답변
Andrei Bobrov
2012년 12월 17일
편집: Andrei Bobrov
2012년 12월 17일
C = [];
for j1 = 1:numel(B)
a = nchoosek(B,j1);
C = [C;num2cell([repmat(A,size(a,1),1),a],2)];
end
추가 답변 (1개)
Walter Roberson
2012년 12월 17일
You cannot create a numeric matrix with a variable number of elements in each row.
댓글 수: 4
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!