How to remove identical pair of data from a matrix in MATLAB?

I have a Nx2 matrix with identical pairs. Something like this:
b_data = [ 1 2; 3 4; 7 10; 2 1; 10 7; 11 12];
i consider 1 2, 2 1 as identical
I need to make this
b_data = [1 2; 3 4;7 10; 11 12];
Is there any command for doing so?

 Accepted Answer

use something like
unique(sort([1 2; 2 1; 3 5],2),'rows')

4 Comments

The unique function will already sort the output, unless you specify 'stable'. This has been the case for a long time already.
yes, but without sorting each row before using unique, the rows 1 2 and 2 1 will appear both
Ah, sorry, I must have read it too quickly. Have an upvote as an apology.
no problem, i also often read faster than i can think ;)

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2021a

Asked:

on 11 May 2021

Commented:

on 11 May 2021

Community Treasure Hunt

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

Start Hunting!