函数intersect的用法:
1)INTERSECT(A,B) for vectors A and B, returns the values common to the
two vectors. MATLAB sorts the results. A and B can be cell arrays of
strings. %求A向量和B向量的交集。
A=[1 2 3 6 8 9];B=[1 2 8];
C=intersect(A,B)
C =
1 2 8
2) INTERSECT(A,B,'rows') for matrices A and B that have the same number of
columns, returns the rows common to the two matrices. MATLAB ignores
the 'rows' flag for all cell arrays. % 对于矩阵A和矩阵B,其列数相同,返回相同的行。
A=[1 2 3;2 3 4;3 4 5];B=[1 2 4;2 3 4;3 4 7];
C=intersect(A,B,'rows')
3) [C,IA,IB] = INTERSECT(A,B) also returns index vectors IA and IB
such that C = A(IA) and C = B(IB). %C是A和B相交之后得到的数据,IA是C在A中的索引值,IB是C在B中的索引