Linear Algebra

Linear Algebra Blocks

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. See Working with Signals for more information about matrix signals.

Linear System Solvers

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

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

Example: LU Solver

In the model below, the LU Solver block solves the equation Ax = b, where

and finds x to be the vector [-2 0 1]'.

To build the model, set the following parameters:

You can verify the solution by using the Matrix Multiply block to perform the multiplication Ax, as shown in the model below.

Matrix Factorizations

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 particularly suited to factoring a Hermitian positive definite matrix into triangular components, whereas the QR Factorization is particularly suited to factoring a rectangular matrix into unitary and upper triangular components.

Example: LU Factorization

In the model below, the LU Factorization block factors a matrix Ap into upper and lower triangular submatrices U and L, where Ap is row equivalent to input matrix A, where

To build the model, in the DSP Constant block, set the Constant value parameter to [1 -2 3;4 0 6;2 -1 3], clear the Interpret vector parameters as 1–D check box, set theSampling mode to Sample based, and set the Sample time to 1.

The lower output of the LU Factorization, P, is the permutation index vector, which indicates that the factored matrix Ap is generated from A by interchanging the first and second rows.

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 Ap.

You can check that LU = Ap with the Matrix Multiply block, as shown in the model below.

Matrix Inverses

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

Example: LU Inverse

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

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

To build the model, set the Constant block parameters as follows:

As shown above, the computed inverse is

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS