ismember 判断A中的元素在B中有没有出现
LIA = ismember(A,B) for arrays A and B returns an array of the same size as A containing true where the elements of A are in B and false otherwise.
对于数组A合B,返回一个和A同样尺寸的数组,若A某位置的元素在B中出现,则LIA相应位置为true,否则为false
LIA = ismember(A,B,'rows') for matrices A and B with the same number of columns, returns a vector containing true where the rows of A are also rows of B and false otherwise.
对于具有同样列数的A和B,返回一个向量,行数和A相同,如果A的该行在B中出现,则LIA该行的值为1,如果A的该行在B中没有出现过,返回0

[LIA,LOCB] = ismember(A,B) also returns an array LOCB containing the highest absolute index in B for each element in A which is a member of  B and 0 if there is no such index.
LOCB和数组A的大小一样,里面包含A中元素在B中出现的位置,最大绝对值位置,即如果B中有两个元素和A中某元素相同,那么就返回索引值最大的那个位置
[LIA,LOCB] = ismember(A,B,'rows') also returns a vector LOCB containing  the highest absolute index in B for each row in A which is a member of B and 0 if there is no such index.
同上
In a future release, the behavior of ismember will change including:
- occurrence of indices in LOCB will switch from highest to lowest
- tighter restrictions on combinations of classes

In order to see what impact those changes will have on your code, use:

[LIA,LOCB] = ismember(A,B,'R2012a')
[LIA,LOCB] = ismember(A,B,'rows','R2012a')

If the changes in behavior adversely affect your code, you may preserve
the current behavior with:

[LIA,LOCB] = ismember(A,B,'legacy')
[LIA,LOCB] = ismember(A,B,'rows','legacy')

Examples:

a = [9 9 8 8 7 7 7 6 6 6 5 5 4 4 2 1 1 1]
b = [1 1 1 3 3 3 3 3 4 4 4 4 4 9 9 9]

[lia1,locb1] = ismember(a,b)
% returns
lia1 = [1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1]
locb1 = [16 16 0 0 0 0 0 0 0 0 0 0 13 13 0 3 3 3]

[lia2,locb2] = ismember(a,b,'R2012a')
% returns
lia2 = [1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 1 1 1]
locb2 = [14 14 0 0 0 0 0 0 0 0 0 0 9 9 0 1 1 1]

[lia,locb] = ismember([1 NaN 2 3],[3 4 NaN 1])
% NaNs compare as not equal, so this returns
lia = [1 0 0 1], locb = [4 0 0 1]

Class support for inputs A and B, where A and B must be of the same
class unless stated otherwise:
- logical, char, all numeric classes (may combine with double arrays)
- cell arrays of strings (may combine with char arrays)
-- 'rows' option is not supported for cell arrays
- objects with methods SORT (SORTROWS for the 'rows' option), EQ and NE
-- including heterogeneous arrays derived from the same root class

ismember matlab的更多相关文章

  1. Matlab中ismember用法

    >> a = magic(3) a = 8 1 6 3 5 7 4 9 2 >> ismember(a,3) ans = 0 0 0 1 0 0 0 0 0 >> ...

  2. matlab函数_连通区域

    1. matlab函数bwareaopen──删除小面积对象格式:BW2 = bwareaopen(BW,P,conn)作用:删除二值图像BW中面积小于P的对象,默认情况下使用8邻域.算法:(1)De ...

  3. 蚁群算法求解旅行商问题(附c和matlab源代码)

    前几天写了个模拟退火算法的程序,然后又陆陆续续看了很多群智能算法,发现很多旅行商问题都采用蚁群算法来求解,于是开始写蚁群算法的模板.网上关于蚁群算法的理论很多就不再这里赘述了,下面直接上代码和进行简单 ...

  4. MATLAB命令大全

    一.常用对象操作:除了一般windows窗口的常用功能键外.1.!dir 可以查看当前工作目录的文件. !dir& 可以在dos状态下查看.2.who 可以查看当前工作空间变量名, whos ...

  5. matlab函数bwareaopen的详解

    matlab函数_连通区域 1. matlab函数bwareaopen──删除小面积对象格式:BW2 = bwareaopen(BW,P,conn)作用:删除二值图像BW中面积小于P的对象,默认情况下 ...

  6. Matlab图像处理函数:regionprops

    本篇文章为转载,仅为方便学术讨论所用,不用于商业用途.由于时间较久,原作者以及原始链接暂时无法找到,如有侵权以及其他任何事宜欢迎跟我联系,如有侵扰,在此提前表示歉意.----------------- ...

  7. MATLAB 编程风格指南及注意事项

    MATLAB编程风格指南Richard Johnson 著Genial 译MATLAB 编程风格指南Richard JohnsonVersion 1.5,Oct. 2002版权: Datatool 所 ...

  8. MATLAB连通域标记函数

    L = bwlabel(BW,n)返回一个和BW大小相同的L矩阵,包含了标记了BW中每个连通区域的类别标签,这些标签的值为1.2.num(连通区域的个数).n的值为4或8,表示是按4连通寻找区域,还是 ...

  9. MATLAB函数表(转自:http://bbs.06climate.com/forum.php?mod=viewthread&tid=16041&extra=page%3D4)

    MATLAB函数表 4.1.1特殊变量与常数 ans 计算结果的变量名 computer 确定运行的计算机 eps 浮点相对精度 Inf 无穷大 I 虚数单位 inputname 输入参数名 NaN ...

随机推荐

  1. EnterpriseDB公司的 Postgres Solution Pack (一)

    下载地址: http://www.enterprisedb.com/products-services-training/products/postgres-plus-solution-pack/do ...

  2. 成都Uber优步司机奖励政策(1月11日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  3. 长沙Uber优步司机奖励政策(1月4日~1月10日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  4. nio之netty3的应用

    1.netty3是nio的封装版本.在使用上面比nio的直接使用更好.nio简单使用都是单线程的方式(比如:一个服务员服务很多客户),但是netty3的方式不一样的是,引入线程池的方式来实现服务的通信 ...

  5. HardcodedDebugMode

    xmlns:tools="http://schemas.android.com/tools" tools:ignore="HardcodedDebugMode"

  6. 「Python」conda与pip升级所有的包

    conda: conda update --a pip: pip freeze --local | grep -v '^-e' | cut -d = -f 1 | xargs -n1 sudo pip ...

  7. 用Anko和Kotlin实现Android上的对话框和警告提示(KAD 24)

    作者:Antonio Leiva 时间:Mar 9, 2017 原文链接:https://antonioleiva.com/dialogs-android-anko-kotlin/ 借助Builder ...

  8. DEDEcms调用当前栏目顶级栏目url地址

    include/common.func.php 找到这个文件 在文件最下方加入以下代码: //获取顶级栏目url function GetTopTypeurl($id) { global $dsql; ...

  9. a链接传参的方法

    //获取分案编号 var hrefVal=window.location.href.split("?")[1]; //得到id=楼主 //console.log(hrefVal+& ...

  10. Apache——SSL协议

    SSL 协议既用到了公钥加密技术又用到了对称加密技术,对称加密技术虽然比公钥加密技术的速度快,可是公钥加密技术提供了更好的身份认证技术.SSL 的握手协议非常有效的让客户和服务器之间完成相互之间的身份 ...