Solving Linear Systems
• lsolve(M, v)—Returns the solution x for the linear system of equations M·x = v, using LU factorization.
Arguments
• M is a real or complex matrix. If the matrix is square, it must be nonsingular.
• v is a real or complex vector or matrix having the same number of rows as M.
Additional Information
• A matrix is singular if its determinant is 0. It is nearly singular if it has a high condition number. These conditions make it difficult to compute the inverted matrix used to solve the problem. The lsolve function may fail or may produce meaningless results in these cases. You may wish to use other decompositions for nearly singular matrices.
• The lsolve function is based on a routine from the book Press, W. H., et. al., Numerical Recipes in C: The Art of Scientific Computing, second ed., Cambridge University Press, Cambridge, 1992. The BLAS/LAPACK libraries from Intel are used for LU factorization.
• You can check if a system has a unique solution by checking if rank(M) = cols(M), that is, if all the columns of M are linearly independent.
• You can use matrix inversion directly to solve this type of system, but lsolve is faster, and, in some cases, more accurate. To solve a linear system of equations in natural notation, you may wish to use a solve block.
• In the case of an inconsistent system of equations, lsolve returns the least-squares solution, given also by geninv(M)·v.
• For matrix values of v, lsolve(M, v<i>) returns the ith column of geninv(M)·v.