%% Condition Number of Matrix
% Calculate the condition number of a matrix and examine the sensitivity to the inverse calculation.
%
% Create a 2-by-2 matrix.

A = [4.1 2.8;
     9.7 6.6];

%
% Calculate the 2-norm condition number of A.

C = cond(A)

%
% Since the condition number of A is much larger than 1, the matrix is sensitive to the inverse calculation. Calculate the inverse of A, and then make a small change in the second row of A and calculate the inverse again.

invA = inv(A)

%

A2 = [4.1    2.8; 
      9.671  6.608]
invA2 = inv(A2)

% The results indicate that making a small change in A can completely change the result of the inverse calculation.
% Copyright 2012 The MathWorks, Inc.