Skip to content

eye

Identity matrix

eye

  • It returns 1.

eye(n)

  • n should be non-negative integer.
  • It returns the n-by-n identity matrix.
  • If n is not positive, the result would be an empty matrix.
  • If n is not integer, n would be rounded towards zero.
  • It does not accept ±nan, or ±inf as argument.

eye(m, n)

eye([m n])

  • m and n should be non-negative integers.
  • It returns an m-by-n matrix.
  • If m < n, the first m columns form an identity matrix, while the last n - m columns contain only zeros.
  • If m > n, the first n rows form an identity matrix, while the last m - n rows contain only zeros.
  • If m or n is not positive, the result would be empty matrix.
  • If m or n is not integer, it would be rounded towards zero.
  • It does not accept ±nan, or ±inf as argument.