Search code examples
matlabmathinverse

Matlab: How to compute the inverse of a matrix


I want to find the T inverse as given in the picture. The first picture is the matrix T and the other is T inverse.

T

T inverse

I = eye(3);
T = [I/2, (j/2)*I, 0;
     I/2,  (-j/2)*I, 0;
     0,0,I];

Error using horzcat CAT arguments dimensions are not consistent.

Then I tried with I = eye(2) and got the same error. What is the proper way?


Solution

  • Given

    I = eye(3);
    

    you want to multiply element-wise using .* with A (make sure you use the imaginary unit 1j and not an undefined variable j)

    A = [1/2, (1j/2), 0;
         1/2,  (-1j/2), 0;
         0,0,1];
    

    to get T

    T = A.*I
    

    But apart from that it feels like you actually want to multiply A with a constant C = I = 1

    T = A.*1
    

    The inverse you obtain with the inverse function:

    Tinv = inv(T)