# How To Generate Unit Matrices In Short Way In MatLab®(Illustrated Epression)

As you know Matlab® has various tools and commands to obtain matrices shortly. Because the general mathematical calculations are done with matrices in Matlab®. Also, unit matrices are frequently used in Matlab® to do special mathematical calculations. So Matlab® has a special command that creates unit matrices called the ‘eye’ command. The use of the ‘eye’ command to obtain unit matrices is very basic. And there is a basic example about the use of the ‘eye’ command in Matlab®. Also, you will find information about how is the syntax of the ‘eye’ command in Matlab in this text.

YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!

## How To Use Eye Command In Matlab®?

``````>> v = eye(3)
z = 5.*v
d = 5.*eye(5)

v =

1     0     0
0     1     0
0     0     1

z =

5     0     0
0     5     0
0     0     5

d =

5     0     0     0     0
0     5     0     0     0
0     0     5     0     0
0     0     0     5     0
0     0     0     0     5

>> ``````

As you can see from above, the use of ‘eye’ is very basic. The general use of the ‘eye’ command in Matlab® is like in the v variable. You simply type eye then type your square matrix dimension inside parentheses right after it. So v variable is obtained as a 3×3 square unit matrix with ‘eye’ command in Matlab®.

Also, you can do mathematical calculations with the ‘eye’ command in Matlab® as shown by the z variable above. The v variable which has obtained with the ‘eye’ command simply multiplied with the number of 5. You can see the result that the unit axis of the z matrix comprises only the number of 5.

You can directly do mathematical calculations with the ‘eye’ command as in the d variable above. We add 5 to the eye(5) unit matrix in variable d. Then you can see the result that the whole elements in the d matrix added with the number of 5.

## Conclusion

So, you can understand that you could obtain various kinds of matrices in Matlab® in a short way by using various matrix generator codes such as this ‘eye’ command.

Do not forget to leave your comments and questions below about the use of the ‘eye()’ command in Matlab® below.

If you want further coding examples about the ‘eye()’ command in Matlab®, inform us in the comments.