MATLAB: Removing rows that are not unique from an array

unique

Is there an easy way to remove ALL rows that are NOT unique? For example, how would I get B from A?
A = [1 2; 1 3; 1 4; 1 2; 1 5];
B = [1 3; 1 4; 1 5];
I could do this in a loop, but there seems like there must be a more elegant way. I've looked at various applications in the forum using the unique() function, but a solution is not obvious to me.
Thanks!

Best Answer

This works:
A = [1 2; 1 3; 1 4; 1 2; 1 5];
[~,ia,ic] = unique(A, 'rows'); % Unique Elements
v = accumarray(ic, 1); % Tally Occurrences Of Rows
B = A(ia(v==1),:) % Keep Rows That Only Appear Once
B =
1 3
1 4
1 5