function InvMat3_

%Beispielmatrix
A=[2 .1 3; exp(0) 4 .3; pi .5 .7]

A_Inv=InvMat3(A)

%Test
A*A_Inv

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Matrix-Inversion fuer 3x3-Matrizen mit Determinanten
function A_Inv=InvMat3(A)

%Determinante von A
Det_A=A(1,1)*Sub_Det(A,1,1)-A(1,2)*Sub_Det(A,1,2)+A(1,3)*Sub_Det(A,1,3)

%Matrixelemente der Inversen
for i=1:3
    for j=1:3
        A_Inv(i,j)=(-1)^(j-i)*Sub_Det(A,j,i)/Det_A;
    end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Unterdeterminaten
function D=Sub_Det(A,i,j)
i1=[2 3 1];
i2=[3 1 2];
D=(-1)^(i-j)*(A(i1(i),i1(j))*A(i2(i),i2(j))-A(i1(i),i2(j))*A(i2(i),i1(j)));

