博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
matlab 集合运算 交集 并集 差集
阅读量:4286 次
发布时间:2019-05-27

本文共 638 字,大约阅读时间需要 2 分钟。

1.求两个集合的交集 使用函数 intersect

C = intersect(A,B) for vectors A and B, returns the values common to  the two vectors with no repetitions. C will be sorted.

>> a=[3 2 1];

>> b=[2 1 6 8];
>> c=intersect(a,b)

c =

     1     2

2. 求两个集合的并集 使用函数 union

 C = union(A,B) for vectors A and B, returns the combined values of the two vectors with no repetitions. C will be sorted.

>> a=[3 2 1];

>> b=[2 1 6 8 2];
>> c=union(a,b)

c =

     1     2     3     6     8

 

3. 求两个集合的差集,如A-B,仅在集合A中存在不在集合B中存在的元素 使用函数setdiff

C = setdiff(A,B) for vectors A and B, returns the values in A that are not in B with no repetitions. C will be sorted.

>> a=[3 2 1];

>> b=[2 1 6 8 2];
>> c=setdiff(a,b)

c =

     3

 

转载地址:http://bpxgi.baihongyu.com/

你可能感兴趣的文章
Servlet技术浅析(八)之-----浏览器缓存浅析
查看>>
Servlet技术浅析(九)之-----下载文件和上传文件
查看>>
一台linux操作系统上配置多台Tomcat服务
查看>>
maven入门浅析(二)-----maven集成eclipse、jboss
查看>>
正则表达式入门教程(三)
查看>>
SyntaxError: identifier starts immediately after numeric literal错误解决办法
查看>>
正则表达式入门教程(四)
查看>>
JAVA程序员成长之路的总结
查看>>
javaEE工程师学习路线图
查看>>
java工程师进阶之路
查看>>
linux系统一个tomcat配置两个域名,每个域名对应一个项目
查看>>
javaScript使用Lodop实现网页表格套打功能
查看>>
技术大牛如何寻找下一个风口
查看>>
大数据学习路线大纲
查看>>
html入门之meta
查看>>
mvn不是内部或外部命令,也不是可运行的程序或批处理文件
查看>>
JAVA:JDBC连接MySQL数据库
查看>>
struts2流程简述
查看>>
struts2文件上传和下载
查看>>
值栈与OGNL
查看>>