[英]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?
[英]How to remove all vectors from a cell B which belong to A or which are contained in one vector from A?
A = {[1 2 3 4],[22 55 78 84],[50 21 98 71],[10 15 16]};
B = {[2 4],[20 30 55],[16 15 10],[22 55 78]};
如何从属于A的单元格B中删除所有向量或从A中包含在一个向量中的向量?
我的例子的理想结果
out = {[20 30 55]}
单行:
out = B(~cellfun(@(y) any(cellfun(@(x) all(ismember(y,x)), A)), B));
代码的解释只是说,换句话说,你问什么:内cellfun
检测是否向量B
完全由的载体之一包含A
,外cellfun
组装这些结果对于所有B
载体。 得到的逻辑向量( B
的大小)被否定,因为你想要B
唯一向量,而不是A
“嵌入”的向量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.