Main Content

Solve systems of linear equations *Ax = B* for *x*

solves the system of linear equations `x`

= `A`

\`B`

```
A*x =
B
```

. The matrices `A`

and
`B`

must have the same number of
rows. MATLAB^{®} displays a warning message if
`A`

is badly scaled or nearly
singular, but performs the calculation regardless.

If

`A`

is a scalar, then`A\B`

is equivalent to`A.\B`

.If

`A`

is a square`n`

-by-`n`

matrix and`B`

is a matrix with`n`

rows, then`x = A\B`

is a solution to the equation`A*x = B`

, if it exists.If

`A`

is a rectangular`m`

-by-`n`

matrix with`m ~= n`

, and`B`

is a matrix with`m`

rows, then`A`

\`B`

returns a least-squares solution to the system of equations`A*x= B`

.

The operators

`/`

and`\`

are related to each other by the equation`B/A = (A'\B')'`

.If

`A`

is a square matrix, then`A\B`

is roughly equal to`inv(A)*B`

, but MATLAB processes`A\B`

differently and more robustly.If the rank of

`A`

is less than the number of columns in`A`

, then`x = A\B`

is not necessarily the minimum norm solution. You can compute the minimum norm least-squares solution using`x =`

or`lsqminnorm`

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

`mrdivide`

| `ldivide`

| `rdivide`

| `inv`

| `pinv`

| `chol`

| `lu`

| `qr`

| `ldl`

| `linsolve`

| `lsqminnorm`

| `spparms`

| `decomposition`