Inf
Positive infinity, as a scalar or an array of the requested size and class.
Category: Language Fundamentals > Data Types
Syntax
x = Inf
Returns the scalar infinity.
X = Inf(n)
Returns an n-by-n matrix of Inf.
X = Inf(sz1, ..., szN)
Returns an array with the given dimensions.
X = Inf(___, classname)
Creates it as 'double' or 'single'.
Description
Inf arises from overflow and from division of a nonzero number by zero: 1/0 is Inf. It follows IEEE rules: Inf + 1 is Inf, while Inf - Inf and 0 * Inf are NaN. Use isinf to test for it, and -Inf for negative infinity.
Input arguments
n, sz1, ..., szN- Dimensions of the result.
classname'double'(default) or'single'.
Output arguments
X- Array filled with
Inf.
Example
Creating and combining Inf
Inf(2, 3)
class(Inf('single'))
1/0
Inf - Inf
isinf([1 Inf -Inf NaN])
Output
ans = 2×3
Inf Inf Inf
Inf Inf Inf
ans = 'single'
ans = Inf
ans = NaN
ans = 1×4 logical array
0 1 1 0