matlab中的isnan函数怎么用,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*∞”都会产生这种结果。好了我相信大家应该知道这个函数的用法了吧。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值