the isnumeric function and the NaN

조회 수: 40 (최근 30일)
Snoopy
Snoopy 2018년 9월 7일
편집: Snoopy 2018년 9월 7일
I have a matrix array (A) that includes three column arrays. All columns contain integers except that one of the columns also include NaNs. When I type isnumeric(A), the output is a logical value 1. Apparently NaN is recognised as a numeric entry as otherwise MATLAB would return a logical value of 0. How is a NaN recognised exactly?
  댓글 수: 6
Stephen23
Stephen23 2018년 9월 7일
편집: Stephen23 2018년 9월 7일
@Snoopy: The behavior of NaN's within MATLAB operations is explained here:
NaN's are just a particular bit pattern that is assigned to have the value Not-a-Number. To know more about the classes that support NaN's, you need to read about IEEE 754 standard (the well-supported 1985 version), which defines the floating point numbers that MATLAB uses:
This also explains how the numbers are stored, including the "special" values like Inf and NaN:
Snoopy
Snoopy 2018년 9월 7일
편집: Snoopy 2018년 9월 7일
This is it. Thanks for the effort and time put into the answer. I wanted to accept this as answer but it seems comment cannot be marked as such. Sorry for this.

댓글을 달려면 로그인하십시오.

답변 (1개)

Cesar Antonio Lopez Segura
Cesar Antonio Lopez Segura 2018년 9월 7일
Hi,
Write this in your command window:
isnan( [ 0 1 NaN] )

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by