主要内容

isequaln

Determine array equality, treating NaN values as equal

Description

example

tf = isequaln(A,B)returns logical1(真正) ifABare equivalent; otherwise, it returns logical0(false)。看看Input Argumentssection for a definition of equivalence for each data type.NaN(不是一个数字),NaT(不是时间),未定义的分类元素,和<缺失>values are considered to beequalto other such values.

To treatNaN,NaT,<未定义>,和<缺失>values as unequal to other such values, useisequal.

example

tf = isequaln(A1,A2,...,An)returns logical1(真正) if all the inputs are equivalent.

Examples

collapse all

Create two numeric matrices and compare them for equality.

A =零(3,3)+ 1E-20;B =零(3,3);tf = isequaln(a,b)
tf =logical0

该函数返回逻辑0(false)因为矩阵的差异非常少量并且不是究竟等于。

创建两个结构并以不同的顺序指定字段。

a = struct('field1',0.005,'field2',2500);b = struct('field2',2500,'field1',0.005);

Compare the structures for equality.

tf = isequaln(a,b)
tf =logical1

Even though the ordering of the fields in each structure is different,isequaln将它们视为相同的,因为值相等。

Compare the logical value真正到双整数1.

isequaln(真实,1)
ans =logical1

Notice thatisequalndoes not consider data type when it tests for equality.

Similarly, compare'A'到ASCIIS等效的整数,65.

isequaln('A',65)
ans =logical1

The result is logical1(真正) sincedouble('A')等于65.

Create three vectors containing NaN values.

A1 = [1 NaN NaN]; A2 = [1 NaN NaN]; A3 = [1 NaN NaN];

比较矢量的平等。

tf = isequaln(a1,a2,a3)
tf =logical1

The result is logical1(真正) becauseisequalntreats the NaN values as equal to each other.

Even though the sizes and data types are different,isequalnreturns logical1(真正)在比较包含相同字符序列的字符向量和字符串标量时。

isequaln("foo",'foo')
ans =logical1

Input Arguments

collapse all

Inputs to be compared, specified as arrays.

在某些情况下,输入类型不必匹配:

  • Numeric inputs are equivalent if they are the same size and their contents are of equal value. The test compares both real and imaginary parts of numeric arrays.

  • Tables, timetables, structures, and cell arrays are equivalent only when all elements and properties are equal.

  • 字符串标量和性格vectors containing the same sequence of characters are equivalent.

一些数据类型比较具有涉及元数据的特殊考虑因素。如果输入是所有:

  • Structures — Fields need not be in the same order as long as the contents are equal.

  • Ordinal categorical arrays — Must have the same sets of categories, including their order.

  • 非序数的分类阵列 - 可以具有不同的类别组,以及isequalncompares the category names of each pair of elements.

  • DateTime阵列 -isequalnignores display format when it compares points in time. If the arrays are all associated with time zones, thenisequalncompares the instants in time rather than the clockface times (for example,01-5月 - 2018 09:00:00 EDTis the same instant as01-May-2018 06:00:00 PDT, soisequalnreturns真正even though the clockface times of 9:00 and 6:00 differ).

  • Objects —isequalnreturns logical1(真正) for objects of the same class with equal property values.

Series of inputs to be compared, specified as arrays.

在某些情况下,输入类型不必匹配:

  • Numeric inputs are equivalent if they are the same size and their contents are of equal value. The test compares both real and imaginary parts of numeric arrays.

  • Tables, timetables, structures, and cell arrays are equivalent only when all elements and properties are equal.

  • 字符串标量和性格vectors containing the same sequence of characters are equivalent.

一些数据类型比较具有涉及元数据的特殊考虑因素。如果输入是所有:

  • Structures — Fields need not be in the same order as long as the contents are equal.

  • Ordinal categorical arrays — Must have the same sets of categories, including their order.

  • 非序数的分类阵列 - 可以具有不同的类别组,以及isequalncompares the category names of each pair of elements.

  • DateTime阵列 -isequalnignores display format when it compares points in time. If the arrays are all associated with time zones, thenisequalncompares the instants in time rather than the clockface times (for example,01-5月 - 2018 09:00:00 EDTis the same instant as01-May-2018 06:00:00 PDT, soisequalnreturns真正even though the clockface times of 9:00 and 6:00 differ).

  • Objects —isequalnreturns logical1(真正) for objects of the same class with equal property values.

提示

  • The equality of two function handles depends on how they are constructed. For more information, seeCompare Function Handles.

  • isequalnreturns logical0(false) for two objects with dynamic properties, even if the properties have the same names and values.

  • isequalncompares only stored (non-dependent) properties when testing two objects for equality.

  • When comparing two handle objects, use==.to test whether objects have the same handle. Useisequalnto determine if two objects with different handles have equal property values.

Extended Capabilities

C/C++ Code Generation
使用MATLAB®Coder™生成C和C ++代码。

在R2012A介绍