Professional Documents
Culture Documents
Y = inv(X)
Description
example
Y = inv(X) computes the inverse of square matrix X.
X^(-1) is equivalent to inv(X).
x = A\b is computed differently than x = inv(A)*b and is recommended for solving systems
of linear equations.
Examples
collapse all
Inverse Matrix
Try this Example
Compute the inverse of a 3-by-3 matrix.
X = [1 0 2; -1 5 0; 0 3 -9]
X =
1 0 2
-1 5 0
0 3 -9
Y = inv(X)
Y =
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
ans =
1.0000 0 -0.0000
0 1.0000 -0.0000
0 0 1.0000