www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/DetermineifMatrixIsSingularExample.m
%% Determine if Matrix Is Singular % Examine why the determinant is not an accurate measure of singularity. %% % Create a 10-by-10 matrix by multiplying an identity matrix, |eye(10)|, by % a small number. A = eye(10)*0.0001; %% % The matrix |A| has very small entries along the main diagonal. However, % |A| is _not_ singular, because it is a multiple of the identity matrix. %% % Calculate the determinant of |A|. d = det(A) %% % The determinant is extremely small. A tolerance test of the form % |abs(det(A)) < tol| is likely to flag this matrix as singular. Although % the determinant of the matrix is close to zero, |A| is actually not ill % conditioned. Therefore, |A| is not close to being singular. The % determinant of a matrix can be arbitrarily close to zero without % conveying information about singularity. %% % To investigate if |A| is singular, use either the |cond| or |rcond| % functions. %% % Calculate the condition number of |A|. c = cond(A) %% % The result confirms that |A| is not ill conditioned.