Accelerating the pace of engineering and science

• Trials

# Inf

## Syntax

• Inf
• I = Inf(n)
• I = Inf(sz1,...,szN)
• I = Inf(sz)
• I = Inf(classname)
• I = Inf(n,classname)
• I = Inf(sz1,...,szN,classname)
• I = Inf(sz,classname)
• I = Inf('like',p)
• I = Inf(n,'like',p)
• I = Inf(sz1,...szN,'like',p)
• I = Inf(sz,'like',p)

## Description

Inf returns the IEEE® arithmetic representation for positive infinity. Infinity values result from operations like division by zero and overflow, which lead to results too large to represent as conventional floating-point values.

I = Inf(n) is an n-by-n matrix of Inf values.

I = Inf(sz1,...,szN) is a sz1-by-...-by-szN array of Inf values where sz1,...,szN indicates the size of each dimension. For example, Inf(3,4) returns a 3-by-4 array of Inf values.

I = Inf(sz) is an array of Inf values where the size vector, sz, defines size(I). For example, Inf([3,4]) returns a 3-by-4 array of Inf values.

 Note   The size inputs sz1,...,szN, as well as the elements of the size vector sz, should be nonnegative integers. Negative integers are treated as 0.

I = Inf(classname) returns an Inf value where the string, classname, specifies the data type. classname can be either 'single' or 'double'.

I = Inf(n,classname) returns an n-by-n array of Inf values of data type classname.

I = Inf(sz1,...,szN,classname) returns a sz1-by-...-by-szN array of Inf values of data type classname.

I = Inf(sz,classname) returns an array of Inf values where the size vector, sz, defines size(I) and classname defines class(I).

I = Inf('like',p) returns an array of Infs of the same data type, sparsity, and complexity (real or complex) as the numeric variable, p.

I = Inf(n,'like',p) returns an n-by-n array of Inf values like p.

I = Inf(sz1,...szN,'like',p) returns a sz1-by-...-by-szN array of Inf values like p.

I = Inf(sz,'like',p) returns an array of Inf values like p where the size vector, sz, defines size(I).

## Examples

1/0, 1.e1000, 2^2000, and exp(1000) all produce Inf.

log(0) produces -Inf.

Inf-Inf and Inf/Inf both produce NaN (Not-a-Number).