In linear algebra, a diagonal matrix is a matrix in which the entries outside the main diagonal are all zero. The term usually refers to square matrices. An example of a 2-by-2 diagonal matrix is ; the following matrix is a 3-by-3 diagonal matrix:. An identity matrix of any size, or any multiple of it, will be a diagonal matrix.