Skip to content

mldivide

Matrix left division (A \ B).

C = mldivide(A, B)

Returns A \ B — the solution X to A * X = B. For square non-singular A, equivalent to inv(A) * B but faster and more numerically stable. For non-square A, returns the least-squares solution. Same as the \ operator on matrices.

For large or specially-structured systems, linsolve lets you provide structure hints for additional speed.

A = magic(3); b = [15; 15; 15];
x = A \ b % solves A*x = b
norm(A*x - b) % near-zero
  • mrdivide — Matrix right division (A / B).
  • linsolve — Solve a linear system with optional structure hints.
  • inv — Matrix inverse.