[英]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.