The inv function works for complex matrices as well as real matrices. What do you mean by "didn't work correctly"? Did you get an error or warning message (if so, please post it)? Did the inverse * original not exactly equal the identity (which is the natural result of floating point arithmetic and NOT an error btw)? Or what?
Is there a specific reason you are using inv instead of e.g. slash (/) or backslash (\) or svd etc for the problem you are solving?
E.g.,
>> a = [1 2;3 4] + [5 6;7 8]*1i
a =
Column 1
1 + 5i
3 + 7i
Column 2
2 + 6i
4 + 8i
>> inva = inv(a)
inva =
Column 1
-2 + 1i
1.75 - 0.75i
Column 2
1.5 - 0.5i
-1.25 + 0.25i
>> a*inva
ans =
0.999999999999999 4.44089209850063e-16
-8.88178419700125e-16 1
>> inva*a
ans =
Column 1
1 + 4.44089209850063e-16i
0 - 2.22044604925031e-16i
Column 2
0 + 2.22044604925031e-16i
1 - 2.22044604925031e-16i
