matlab中ismember_ismember matlab
ismember 判斷A中的元素在B中有沒有出現(xiàn)
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.
對(duì)于數(shù)組A合B,返回一個(gè)和A同樣尺寸的數(shù)組,若A某位置的元素在B中出現(xiàn),則LIA相應(yīng)位置為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.
對(duì)于具有同樣列數(shù)的A和B,返回一個(gè)向量,行數(shù)和A相同,如果A的該行在B中出現(xiàn),則LIA該行的值為1,如果A的該行在B中沒有出現(xiàn)過,返回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和數(shù)組A的大小一樣,里面包含A中元素在B中出現(xiàn)的位置,最大絕對(duì)值位置,即如果B中有兩個(gè)元素和A中某元素相同,那么就返回索引值最大的那個(gè)位置
[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
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的matlab中ismember_ismember matlab的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: layui 按钮点击一次后失效_0001
- 下一篇: 通过堡垒机rdp 黑屏_[调优]彻底解决