how to get permutation of each rows of matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
hi
I want to get a matrix which consists all permutation of each rows of previous matrix... For example,
A =
1 2 2
2 2 3
result =
1 2 2
2 1 2
2 2 1
2 2 3
2 3 2
3 2 2
댓글 수: 0
채택된 답변
Andrei Bobrov
2013년 5월 21일
out = [];
for j1 = 1:size(A,1)
out = [out;unique(perms(A(j1,:)),'rows')];
end
댓글 수: 0
추가 답변 (1개)
Thomas
2013년 5월 21일
a=[ 1 2 2
2 2 3];
for ii=1:size(a,1)
q(ii,:,:)=unique(perms(a(ii,:)),'rows');
end
out = reshape(q,[],size(a,2),1)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!