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!