Reputation: 734
The function setdiff(A,B,'rows')
is used to return the set of rows that are in A but not B, with repetitions removed.
Is there any way to do it without removing the repetitions? Thanks a lot.
Upvotes: 0
Views: 112
Reputation: 3071
You can use ismember
instead of setdiff
, to find all the rows of B
that appear in A
.
Because you want only those that NOT appear in A
, use the ~
sign, and finally take all A
rows in these rows indices:
A =
1 2 3
4 5 6
1 2 3
7 8 9
B =
4 5 6
C=A(~ismember(A,B,'rows'),:)
C =
1 2 3
1 2 3
7 8 9
Upvotes: 3