[commonElements, isCommon] = multiIntersect(x)
这个函数查找输入单元格(x)中包含的所有向量数组之间的公共元素。
x中的每个向量数组都有一个可选的长度。输出:
1) commonElements包括所有向量数组之间的公共元素。
2) isCommon是一个与x拥有相同数量的向量数组的单元格,每个向量数组的长度都与x中对应的向量数组的长度相同,并指示元素是否包含在commonElements中。
例子)
1 x ={(11日,19日,11日,4,6,7,9,11],[2 1 15 5、7、11],[1、11、7、6、9、22],[1、7、11]}
[commonElements, isCommon] = multiIntersect(x)
回答)
commonElements = [1,7,11]
isCommon{1} = [1 1 0 0 1 0 0 1 0 1 1 1 1]
isCommon{2} = [0 1 0 0 1 1]
isCommon{3} = [1 1 1 0 0 0]
isCommon{4} = [1 1 1]