Return an identity matrix. If invoked with a single scalar argument,
eye
returns a square matrix with the dimension specified. If you supply two scalar arguments,eye
takes them to be the number of rows and columns. If given a vector with two elements,eye
uses the values of the elements as the number of rows and columns, respectively. For example,eye (3) 1 0 0 0 1 0 0 0 1The following expressions all produce the same result:
eye (2) == eye (2, 2) == eye (size ([1, 2; 3, 4])The optional argument class, allows
eye
to return an array of the specified type, likeval = zeros (n,m, "uint8")Calling
eye
with no arguments is equivalent to calling it with an argument of 1. This odd definition is for compatibility with Matlab.