![](/img/trans.png)
[英]For each vector of the cell A, How to find all possible combinations of its components that are not contained in vectors of the cell B?
[英]Find column vectors contained in B but not in A - MATLAB
我有矩阵A
大小的10x100
和矩阵B
与大小10x200
。
如何找到包含在列向量B
而不是在A
? (A和B的列数不同)
用一个例子来详细说明@ Cheery的评论。
A=[1;4];
B=[1 2 4;4 5 6];
C=setdiff(B',A','rows')';
有关详细信息,请参阅http://www.mathworks.com/help/matlab/ref/setdiff.html
你也可以在这里使用bsxfun
-
Bout = B(:,all(any(bsxfun(@ne,B,permute(A,[1 3 2])),1),3))
样品运行 -
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.