inv - Symbolic matrix inverse

Syntax

R = inv(A)

Description

R = inv(A) returns inverse of the symbolic matrix A.

Examples

The statements

A = sym([2,-1,0;-1,2,-1;0,-1,2]);
inv(A)

return

[ 3/4, 1/2, 1/4]
[ 1/2,   1, 1/2]
[ 1/4, 1/2, 3/4]

The statements

syms a b c d
A = [a b; c d]
inv(A)

return

[  d/(a*d-b*c), -b/(a*d-b*c)]
[ -c/(a*d-b*c),  a/(a*d-b*c)]

Suppose you have created the following M-file.

%% Generate a symbolic N-by-N Hilbert matrix.
function A = genhilb(N)
syms t;
for i = 1:N
        for j = 1:N
        A(i,j) = 1/(i + j - t);
        end
end

Then, the following statement

inv(genhilb(2))

returns

[    -(-3+t)^2*(-2+t), (-3+t)*(-2+t)*(-4+t)] 
[(-3+t)*(-2+t)*(-4+t),     -(-3+t)^2*(-4+t)] 

the symbolic inverse of the 2-by-2 Hilbert matrix.

See Also

vpa, Arithmetic Operations

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS