MATLAB: Finding mismatched elements ~ismember

ismembermismatch

A = [1 2 3;2 3 4;3 4 5;4 5 6;5 6 7;6 7 8;7 8 9]
B = [2 3 4;6 7 8]
flag = ~ismember(A,B,'rows');
index = find(flag);
q = A(index(flag))
The error is
??? Index exceeds matrix dimensions.
and The index finds only first elements of each row. The remaining two should also find it.. So, how to do it.?

Best Answer

q = setdiff(A,B,'rows')