performance - Matlab: removing rows when there are repeated values in columns -


i have problem removing rows when columns identical.

i have used , if loop run time long.

i thinking if there more efficient , faster run time method.

a=[ 2 4 6 8; 3 9 7 9; 4 8 7 6; 8 5 4 6; 2 10 11 2]

i want result be

a=[ 2 4 6 8;     4 8 7 6;     8 5 4 6] 

eliminating 2nd row because of repeated '9' , remove 5th row because of repeated '2'.

you can use sort , diff identify rows repeated values

a = a(all(diff(sort(a'))),:) 

returns

a =      2     4     6     8      4     8     7     6      8     5     4     6 

Comments