Getting Started    

More About Matrices and Arrays

This section shows you more about working with matrices and arrays, focusing on

Linear Algebra

Informally, the terms matrix and array are often used interchangeably. More precisely, a matrix is a two-dimensional numeric array that represents a linear transformation. The mathematical operations defined on matrices are the subject of linear algebra.

Dürer's magic square

provides several examples that give a taste of MATLAB matrix operations. You have already seen the matrix transpose, A'. Adding a matrix to its transpose produces a symmetric matrix.

The multiplication symbol, *, denotes the matrix multiplication involving inner products between rows and columns. Multiplying the transpose of a matrix by the original matrix also produces a symmetric matrix.

The determinant of this particular matrix happens to be zero, indicating that the matrix is singular.

The reduced row echelon form of A is not the identity.

Since the matrix is singular, it does not have an inverse. If you try to compute the inverse with

you will get a warning message

Roundoff error has prevented the matrix inversion algorithm from detecting exact singularity. But the value of rcond, which stands for reciprocal condition estimate, is on the order of eps, the floating-point relative precision, so the computed inverse is unlikely to be of much use.

The eigenvalues of the magic square are interesting.

One of the eigenvalues is zero, which is another consequence of singularity. The largest eigenvalue is 34, the magic sum. That is because the vector of all ones is an eigenvector.

When a magic square is scaled by its magic sum,

the result is a doubly stochastic matrix whose row and column sums are all 1.

Such matrices represent the transition probabilities in a Markov process. Repeated powers of the matrix represent repeated steps of the process. For our example, the fifth power

is

This shows that as k approaches infinity, all the elements in the kth power, Pk, approach 1/4.

Finally, the coefficients in the characteristic polynomial

are

This indicates that the characteristic polynomial

det( A - I )

is

4 - 343 - 642 + 2176

The constant term is zero, because the matrix is singular, and the coefficient of the cubic term is -34, because the matrix is magic!


  Deleting Rows and Columns Arrays