Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Identity matrix

`I = eye`

`I = eye(n)`

`I = eye(n,m)`

`I = eye(sz)`

`I = eye(classname)`

`I = eye(n,classname)`

`I = eye(n,m,classname)`

`I = eye(sz,classname)`

`I = eye('like',p)`

`I = eye(n,'like',p)`

`I = eye(n,m,'like',p)`

`I = eye(sz,'like',p)`

`I = eye`

returns the scalar, `1`

.

`I = eye(`

returns
an `n`

)`n`

-by-`n`

identity matrix with
ones on the main diagonal and zeros elsewhere.

`I = eye(`

returns
a scalar, `classname`

)`1`

, where `classname`

specifies
the data type. For example, `eye('int8')`

returns
a scalar, 8-bit integer.

`I = eye('like',`

returns
a scalar, `p`

)`1`

, with the same data type, sparsity,
and complexity (real or complex) as the numeric variable, `p`

.

Was this topic helpful?