%% Inverse Matrix
% Compute the inverse of a 3-by-3 matrix.

X = [1 0 2; -1 5 0; 0 3 -9]

%

Y = inv(X)

%
% Check the results. Ideally, Y*X produces the identity matrix. Since inv performs the matrix inversion using floating-point computations, in practice Y*X is close to, but not exactly equal to, the identity matrix eye(size(X)).

Y*X

% Copyright 2012 The MathWorks, Inc.