How I find rows with same elements but in flipped manner.

2 views (last 30 days)
Hi, I have a matrix suppose A=[1 2;3 4;2 1; 5 3;4 3]; I need to detect row 1 and 3 as well as row 2 and 5 as unique row. my final matrix should be like A=[1 2;3 4;5 3];
Thank you in Advance

Accepted Answer

Jan
Jan on 22 Sep 2017
Edited: Jan on 22 Sep 2017
A = [1 2;3 4;2 1; 5 3;4 3];
As = sort(A, 2); % [EDITED], was: sortrows(A)
Au = unique(As, 'rows');
  3 Comments
Jan
Jan on 22 Sep 2017
Edited: Jan on 22 Sep 2017
@Raj: This was a mistake. sort(A, 2) is needed, not sortrows(A). See the [EDITED] code.

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!