NaN
Create array of all NaN
values
Description
X = NaN
returns the scalar representation of
"not a number". Operations return NaN
when they have undefined numeric
results, such as 0/0
or 0*Inf
.
X = NaN(
returns an
sz1,...,szN
)sz1
-by-...-by-szN
array of NaN
values, where sz1,...,szN
indicate the size of each dimension. For
example, NaN(3,4)
returns a 3-by-4 matrix.
X = NaN(___,
returns an
array of typename
)NaN
values of data type typename
, which can
be either 'single'
or 'double'
.
Examples
Input Arguments
Tips
X = NaN
returns the scalar, typedouble
, IEEE® representation of "not a number". The exact bit-wise hexadecimal representation of this value isfff8000000000000
. MATLAB® preserves the "not a number" status of alternateNaN
representations and treats all representations equivalently. In some special cases, due to hardware limitations for example, MATLAB does not preserve the exact bit pattern of the alternate representations during computation, and instead uses the canonicalNaN
bit pattern previously described.NaN
values are not equal to each other. As a result, comparison operations involvingNaN
return false, except for the not equal operator~=
. For example,NaN == NaN
returns logical 0 (false
), butNaN ~= NaN
returns logical 1 (true
).NaN
values in a vector are treated as different unique elements. For example,unique([1 1 NaN NaN])
returns the row vector[1 NaN NaN]
.Use the
isnan
orismissing
function to detectNaN
values in an array. Use theanynan
oranymissing
function to determine if any array element isNaN
. Use thermmissing
function to detect and removeNaN
values, and thefillmissing
function to detectNaN
values and replace them with non-NaN
values.
Extended Capabilities
Version History
Introduced before R2006a