matlab 中2个集合相交的运算
2013-10-30 16:58
225 查看
函数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中的索引值。
A=[1 2 3 6 8 9];B=[1 2 8];
[C,IA,IB]=intersect(A,B)
C =
1 2 8
IA =
1 2 5
IB =
1 2 3
4) [C,IA,IB] = INTERSECT(A,B,'rows') also returns index vectors IA and IB such that C = A(IA,:) and C = B(IB,:).
A=[1 2 3;2 3 4;3 4 5];B=[1 2 4;2 3 4;3 4 7];
[ C, IA, IB]=intersect(A,B,'rows')
C =
2 3 4
IA =
2
IB =
2
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中的索引值。
A=[1 2 3 6 8 9];B=[1 2 8];
[C,IA,IB]=intersect(A,B)
C =
1 2 8
IA =
1 2 5
IB =
1 2 3
4) [C,IA,IB] = INTERSECT(A,B,'rows') also returns index vectors IA and IB such that C = A(IA,:) and C = B(IB,:).
A=[1 2 3;2 3 4;3 4 5];B=[1 2 4;2 3 4;3 4 7];
[ C, IA, IB]=intersect(A,B,'rows')
C =
2 3 4
IA =
2
IB =
2
相关文章推荐
- matlab 集合求差运算
- Matlab中的集合运算
- Matlab的集合运算[转]
- Matlab常用的集合运算
- MATLAB中的集合运算
- Matlab的集合运算
- 基于MATLAB的高等数学 集合的运算:交
- Matlab的集合运算
- 多级树集合分裂(SPIHT)算法的过程详解与Matlab实现(7)解码过程——扫描解码
- 位运算表示集合的整数
- MATLAB基本运算
- SQL集合运算 差集 并集 交集
- MATLAB 线性运算之图像相加去噪
- MATLAB 线性运算之减法运算及其应用
- Swift_Set集合(相交、集合、反相交、非包含)
- MATLAB 对矩阵做均值运算
- R语言--在R语言中进行集合运算
- SQL 基础--> 集合运算(UNION 与UNION ALL)
- matlab矩阵合并及相关运算
- 离散数学-集合运算基本法则