mldivide,\
Solve systems of linear equationsAx = Bforx
Syntax
Description
solves the system of linear equationsx
=A
\B
A*x = B
. The matricesA
andB
must have the same number of rows. MATLAB®displays a warning message ifA
is badly scaled or nearly singular, but performs the calculation regardless.
If
A
is a scalar, thenA\B
相当于A.\B
.If
A
is a squaren
-by-n
matrix andB
is a matrix withn
rows, thenx = A\B
is a solution to the equationA*x = B
, if it exists.If
A
is a rectangularm
-by-n
matrix withm ~= n
, andB
is a matrix withm
rows, thenA
\B
returns a least-squares solution to the system of equationsA*x= B
.
Examples
Input Arguments
Output Arguments
Tips
The operators
/
and\
are related to each other by the equationB/A = (A'\B')'
.If
A
is a square matrix, thenA\B
is roughly equal toinv(A)*B
, but MATLAB processesA\B
differently and more robustly.If the rank of
A
is less than the number of columns inA
, thenx = A\B
is not necessarily the minimum norm solution. You can compute the minimum norm least-squares solution usingx =
orlsqminnorm
(A,B)x =
.pinv
(A)*BUse
decomposition
objects to efficiently solve a linear system multiple times with different right-hand sides.decomposition
objects are well-suited to solving problems that require repeated solutions, since the decomposition of the coefficient matrix does not need to be performed multiple times.