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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>INF Infinity Constant
</TITLE>
</HEAD>
<BODY>
<H2>INF Infinity Constant
</H2>
<P>
Section: <A HREF=sec_constants.html> Base Constants </A>
<H3>Usage</H3>
Returns a value that represents positive infinity
for both 32 and 64-bit floating point values.
There are several forms for the <code>Inf</code> function.
The first form returns a double precision <code>Inf</code>.
<PRE>
y = inf
</PRE>
<P>
The next form takes a class name that can be either <code>'double'</code>
<PRE>
y = inf('double')
</PRE>
<P>
or <code>'single'</code>:
<PRE>
y = inf('single')
</PRE>
<P>
With a single parameter it generates a square matrix of <code>inf</code>s.
<PRE>
y = inf(n)
</PRE>
<P>
Alternatively, you can specify the dimensions of the array via
<PRE>
y = inf(m,n,p,...)
</PRE>
<P>
or
<PRE>
y = inf([m,n,p,...])
</PRE>
<P>
Finally, you can add a classname of either <code>'single'</code> or <code>'double'</code>.
<H3>Function Internals</H3>
The infinity constant has
several interesting properties. In particular:
<P>
<DIV ALIGN="CENTER">
<IMG SRC="inf_eqn1.png">
</DIV>
<P>
Note that infinities are not preserved under type conversion to integer types (see the examples below).
<H3>Example</H3>
The following examples demonstrate the various properties of the infinity constant.
<PRE>
--> inf*0
ans =
NaN
--> inf*2
ans =
Inf
--> inf*-2
ans =
-Inf
--> inf/inf
ans =
NaN
--> inf/0
ans =
Inf
--> inf/nan
ans =
NaN
</PRE>
<P>
Note that infinities 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(inf)
ans =
4294967295
--> complex(inf)
ans =
Inf
</PRE>
<P>
</BODY>
</HTML>
|