Reputation: 563
I have matrix A
of size 10x100
and matrix B
with size 10x200
.
How to find the column vectors contained in B
but not in A
? ( A and B do not have the same number of columns)
Upvotes: 1
Views: 85
Reputation: 221574
You can also use bsxfun
here -
Bout = B(:,all(any(bsxfun(@ne,B,permute(A,[1 3 2])),1),3))
Sample run -
A =
2 2 2 2 2
2 2 1 1 1
1 1 2 1 3
B =
3 2 3 2 1 2 2
3 1 3 1 1 1 3
2 3 1 2 1 2 3
Bout =
3 3 1 2
3 3 1 3
2 1 1 3
Upvotes: 1
Reputation: 1447
to elaborate @Cheery's comment with an example.
A=[1;4];
B=[1 2 4;4 5 6];
C=setdiff(B',A','rows')';
more details see http://www.mathworks.com/help/matlab/ref/setdiff.html
Upvotes: 2