isequalwithequalnans
测试数组的相等性,将 NaN 视为相等
兼容性
注意
不推荐使用 isequalwithequalnans
。请改用 isequaln
。
语法
tf = isequalwithequalnans(A, B, ...)
说明
如果输入数组的类型、大小和所含内容相同,tf = isequalwithequalnans(A, B, ...)
返回逻辑值 1
(true
);否则返回逻辑值 0
(false
)。NaN
(非数字)值被视为彼此相等。数字数据类型和结构体字段顺序不必一致。
示例
isequal
和 isequalwithequalnans
以不同方式处理包含 NaN
的数组。isequal
不会将 NaN
视为相等,而 isequalwithequalnans
将其视为相等。
A = [32 8 -29 NaN 0 5.7]; B = A; isequal(A, B) ans = 0 isequalwithequalnans(A, B) ans = 1
NaN
元素在数组中的位置无关紧要。如果它们在要比较的数组中未处于相同位置,isequalwithequalnans
返回零。
A = [2 4 6 NaN 8]; B = [2 4 NaN 6 8]; isequalwithequalnans(A, B) ans = 0
提示
isequalwithequalnans
与 isequal
相同,但 isequalwithequalnans
将 NaN
(非数字)值视为相等,isequal
则视为不等。
isequalwithequalnans
以递归方式比较元胞数组和结构体的内容。如果元胞数组或结构体的所有元素在数值上都相等,isequalwithequalnans
返回逻辑值 1
。
版本历史记录
在 R2006a 之前推出