heaventian 发表于 2007-1-30 22:15

求救,MATALB中NaN

在matalb中, 下面程序:
a=nan
if a==nan, a=2; end
a

结果为什么a仍然是NaN呀?

[ 本帖最后由 ChaChing 于 2009-5-16 17:59 编辑 ]

eight 发表于 2007-1-30 22:25

Because two NaNs are not equal to each other, logical operations involving NaNs always return false, except ~= (not equal). Consequently,
NaN ~= NaN
ans =
   1
NaN == NaN
ans =
   0

and the NaNs in a vector are treated as different unique elements.
unique()
ans =
   1 NaN NaN

Use the isnan function to detect NaNs in an array.
isnan()
ans =
   0   0   1   1

下次请先在matlab帮助中搜索一下

[ 本帖最后由 ChaChing 于 2009-5-16 18:02 编辑 ]

heaventian 发表于 2007-1-30 22:53

谢谢,太懒了我
页: [1]
查看完整版本: 求救,MATALB中NaN