matlab isnan用法

最近看代码,遇到一个函数isnan,网上找了很多资料没有发现有价值的,无奈之下只能阅读手册;


isnan

function:
Array elements that are NaN

 description:

TF = isnan(A) returns an array the same size as A containing logical 1 (true) where the elements of A are NaNs and logical 0 (false) where they are not. For a complex number z, isnan(z) returns 1 if either the real or imaginary part of z is NaN, and 0 if both the real and imaginary parts are finite or Inf.

For any real A, exactly one of the three quantities isfinite(A), isinf(A), and isnan(A) is equal to one

估计大家还是没怎么明白,好的我现在举例说明:

1:

a=[0,1,2,NaN];

isnan(1./a);


result:

1 0 0 1

2:

a=[0,1,2,1];
isnan(0./a);


result:

1 0 0 0;

3;

a=[0,1,2,NaN];
isnan(a);


result:

0 0 0 1

 

 

好了大家是不是发现什么特别之处的啦,发现0和0,0和NaN,之间的乘除关系,结果isnan为logic 1(true),是的,这个是正确的,NaN的意思就是不是一个数,我们可以理解为无穷数。0/0就是NAN,NaN或者nan都是“非数”的意思,“0/0”、“∞/∞”、“0*∞”都会产生这种结果。好了我相信大家应该知道这个函数的用法了吧。

 


 

 

你可能感兴趣的:(matlab isnan用法)