For a square matrix , the command A\b is mathematically equivalent to .
A = magic(3)
A =
8 1 6 3 5 7 4 9 2
b = [1;2;3];
x = A\b
x =
0.050000000000000 0.300000000000000 0.050000000000000
One way to check the answer is to compute a quantity known as the residual. It is (hopefully) close to machine precision, scaled by the size of the entries of the data.
residual = b - A*x
residual =
0 0 0
If the matrix is singular, a warning is produced, but you get an answer anyway.
A = [0 1; 0 0]; % known to be singular
b = [1;2];
x = A\b
Warning: Matrix is singular to working precision.
x =
-Inf Inf
When you get a warning, it's important to check the result rather than blindly accepting it as correct.