This command creates an Identity matrix, after reading this MATLAB eye topic, you will know the theory, and examples, and you will understand how to create Identity matrix in MATLAB.
Syntax:
eye(n)
eye(n,m)
- Foe eye(n), n represents the n columns and n rows.
- Foe eye(n,m), represents the n rows and m columns.
Example: To create a 2×2 identity matrix.
The statement to create an Identity matrix in MATLAB is given as
eye(2)
Output:
ans =
1 0
0 1
Example: To create a 2×3 identity matrix.
eye(2,3)
Output:
ans =
1 0 0
0 1 0
Related Topics
MATLAB diagonal matrixdiag() command or function gives diagonal elements or creates a diagonal matrix, after reading this…
MATLAB matrix inverseinv( ) command or function gives the inverse of a matrix, after reading this MATLAB…
MATLAB onesThis command creates an array of all ones, after reading this MATLAB ones topic, you…
MATLAB titletitle() command puts the title on the plot, after reading this MATLAB title topic, you will…
MATLAB linspacelinspace( ) command or function creates a row vector with elements that are linearly (equally)…