OKPEDIA MATLAB EN MATRICE

How to create identity matrix in Matlab and Octave

To make the identity matrix in Matlab and Octave use the function eye()

eye(n)

The parameter n is the number of rows and columns of the square matrix.

What is an identity matrix? The identity matrix is a square matrix with all the elements of the main diagonal equal to 1. The other elements of the matrix are equal to zero. $$ I_4 = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix} $$

Example 1

Create an identity matrix of dimension 3

eye(3)

The function creates an identity matrix with three rows and three columns.

1 0 0
0 1 0
0 0 1

Example 2

Create an identity matrix of dimension 4

eye(4)

The function creates a four-row, four-column identity matrix.

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

https://how.okpedia.org/en/matlab/how-to-create-identity-matrix-in-matlab-and-octave


Report an error or share a suggestion to enhance this page


Matrix in Matlab/Octave


FacebookTwitterLinkedinLinkedin