Removing Reverse Rows in a Permutation Matrix in Matlab

조회 수: 3 (최근 30일)
Josh Gomes
Josh Gomes 2020년 9월 15일
편집: KALYAN ACHARJYA 2020년 9월 15일
I'm looking for a quick way in Matlab to do the following:
Given a permutation matrix of a vector, say [1 2 3], I would like to remove all duplicate reverse rows.
So the matrix P=perms([1 2 3])
3 2 1
3 1 2
2 3 1
2 1 3
1 3 2
1 2 3
becomes
3 2 1
3 1 2
2 3 1

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 9월 15일
편집: KALYAN ACHARJYA 2020년 9월 15일
P=perms([1 2 3]);
result=P(unique(P(:,2)),:)
result =
3 2 1
3 1 2
2 3 1

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by