1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>NAN Not-a-Number Constant
</TITLE>
</HEAD>
<BODY>
<H2>NAN Not-a-Number Constant
</H2>
<P>
Section: <A HREF=sec_array.html> Array Generation and Manipulations </A>
<H3>Usage</H3>
Returns a value that represents ``not-a-number'' for both 32 and 64-bit
floating point values. This constant is meant to represent the result of
arithmetic operations whose output cannot be meaningfully defined (like
zero divided by zero). There are several forms for the <code>NaN</code> function.
The first form returns a double precision <code>NaN</code>.
<PRE>
y = nan
</PRE>
<P>
The next form takes a class name that can be either <code>'double'</code>
<PRE>
y = nan('double')
</PRE>
<P>
or <code>'single'</code>:
<PRE>
y = nan('single')
</PRE>
<P>
With a single parameter it generates a square matrix of <code>nan</code>s.
<PRE>
y = nan(n)
</PRE>
<P>
Alternatively, you can specify the dimensions of the array via
<PRE>
y = nan(m,n,p,...)
</PRE>
<P>
or
<PRE>
y = nan([m,n,p,...])
</PRE>
<P>
Finally, you can add a classname of either <code>'single'</code> or <code>'double'</code>.
<H3>Example</H3>
The following examples demonstrate a few calculations with the not-a-number constant.
<PRE>
--> nan*0
ans =
NaN
--> nan-nan
ans =
NaN
</PRE>
<P>
Note that <code>NaN</code>s are preserved under type conversion to floating point types (i.e., <code>float</code>, <code>double</code>, <code>complex</code> and <code>dcomplex</code> types), but not integer types.
<PRE>
--> uint32(nan)
ans =
0
--> complex(nan)
ans =
NaN
</PRE>
<P>
</BODY>
</HTML>
|