MATLAB eye

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

 

Leave a Comment

error: Content is protected !!