>> A = [1 2 3; 4 5 6; 7 8 0] A = 1 2 3 4 5 6 7 8 0 >> b = [0; 1; 2] b = 0 1 2 >> x = A\b x = 0.6667 -0.3333 0.0000 >> % Check >> b - A*x ans = 1.0e-15 * -0.0740 -0.2220 0 >> % Enter a singular matrix. >> C = A; >> C(3,3) = 9 C = 1 2 3 4 5 6 7 8 9 >> % Look at its reduced row echelon form to see that it is singular. >> rref(C) ans = 1 0 -1 0 1 2 0 0 0 >> % Try solving a linear system with C as coefficient matrix. >> C\b Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.055969e-18. ans = 1.6667 -2.3333 1.0000 >> % See if this is really a solution. >> b - C*ans ans = 1.0e-15 * 0 -0.8882 0 >> % Looks ok. Try a random right-hand side vector. >> d = rand(3,1) d = 0.9501 0.2311 0.6068 >> C\d Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.055969e-18. ans = 1.0e+15 * -4.9301 9.8601 -4.9301 >> % This system has no solution. >> exit 629 flops.