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.
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
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.175530e-017.
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.
P = 0.4706 0.0882 0.0588 0.3824 0.1471 0.2941 0.3235 0.2353 0.2647 0.1765 0.2059 0.3529 0.1176 0.4412 0.4118 0.0294
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
0.2507 0.2495 0.2494 0.2504 0.2497 0.2501 0.2502 0.2500 0.2500 0.2498 0.2499 0.2503 0.2496 0.2506 0.2505 0.2493
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
This indicates that the characteristic polynomial
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 |