Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

The Matrices and Linear Algebra library provides three large sublibraries containing blocks for linear algebra; Linear System Solvers, Matrix Factorizations, and Matrix Inverses. A fourth library, Matrix Operations, provides other essential blocks for working with matrices.

The Linear System Solvers library provides the following blocks
for solving the system of linear equations A*X* = B:

Some of the blocks offer particular strengths for certain classes of problems. For example, the Cholesky Solver block is adapted for a square Hermitian positive definite matrix A, whereas the Backward Substitution block is suited for an upper triangular matrix A.

In the following ex_lusolver_tut model,
the LU Solver block solves the equation A* x* = b, where

$$A=\left[\begin{array}{ccc}1& -2& 3\\ 4& 0& 6\\ 2& -1& 3\end{array}\right]\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}b=\left[\begin{array}{c}1\\ -2\\ -1\end{array}\right]$$

and finds * x* to be the vector

`[-2 0 1]'`

.

You can verify the solution by using the Matrix Multiply block
to perform the multiplication A* x*, as shown in the
following ex_matrixmultiply_tut1 model.

The Matrix Factorizations library provides the following blocks for factoring various kinds of matrices:

Some of the blocks offer particular strengths for certain classes of problems. For example, the Cholesky Factorization block is suited to factoring a Hermitian positive definite matrix into triangular components, whereas the QR Factorization is suited to factoring a rectangular matrix into unitary and upper triangular components.

In the following ex_lufactorization_tut model,
the LU Factorization block factors a matrix A_{p} into
upper and lower triangular submatrices U and L, where A_{p} is
row equivalent to input matrix A, where

The lower output of the LU Factorization, `P`

,
is the permutation index vector, which indicates that the factored
matrix * A_{p}* is generated from A by interchanging the first and second rows.

$${A}_{p}=\left[\begin{array}{ccc}4& 0& 6\\ 1& -2& 3\\ 2& -1& 3\end{array}\right]$$

The upper output of the LU Factorization, `LU`

,
is a composite matrix containing the two submatrix factors, U and L, whose product LU is equal to A_{p}.

$$U=\left[\begin{array}{ccc}4& 0& 6\\ 0& -2& 1.5\\ 0& 0& -0.75\end{array}\right]\text{}\text{}\text{}\text{}\text{}\text{}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}L=\left[\begin{array}{ccc}1& 0& 0\\ 0.25& 1& 0\\ 0.5& 0.5& 1\end{array}\right]$$

You can check that LU = * A_{p}* with
the Matrix Multiply block, as shown in the following ex_matrixmultiply_tut2 model.

The Matrix Inverses library provides the following blocks for inverting various kinds of matrices:

In the following ex_luinverse_tut model, the LU Inverse block computes the inverse of input matrix A, where

$$A=\left[\begin{array}{ccc}1& -2& 3\\ 4& 0& 6\\ 2& -1& 3\end{array}\right]$$

and then forms the product * A^{-1}*A,
which yields the identity matrix of order 3, as expected.

As shown above, the computed inverse is

$${A}^{-1}=\left[\begin{array}{ccc}-1& -0.5& 2\\ 0& 0.5& -1\\ 0.6667& 0.5& -1.333\end{array}\right]$$

Was this topic helpful?