Sina
Sina

Reputation: 645

Get unique values in matrix with Matlab

I'm looking for fastest way to get unique values in matrix with Matlab! I have a matrix like this:

1       2
1       2
1       3
1       5
1       23
2       1
3       1
3       2
3       2
3       2
4       17
4       3
4       17

and need to get something like this:

1       2
1       3
1       5
1       23
2       1
3       1
3       2
4       3
4       17

Actually I need unique values by combination of columns in each row.

Upvotes: 1

Views: 1363

Answers (1)

user7431005
user7431005

Reputation: 4539

Have a look at matlabs unique() function with the argument 'rows'.

C = unique(A,'rows')

https://de.mathworks.com/help/matlab/ref/unique.html

Upvotes: 5

Related Questions