how to find the inverse of a 2x2xm matrix?

3 views (last 30 days)
padoh
padoh on 2 Aug 2013
i have extracted a 2x2xm matrix from an s2p file and i want to find its inverse. how do i go about doing this?
the question is like this:
a(:,:,1) =
-0.6044 - 0.1389i -5.2117 -32.3236i -0.0019 - 0.0205i -0.6058 - 0.1386i
a(:,:,2) =
-0.5319 - 0.1475i -4.6956 -34.9899i -0.0016 - 0.0213i -0.5335 - 0.1473i
a(:,:,3) =
-0.4557 - 0.1551i -4.1408 -37.3825i -0.0014 - 0.0220i -0.4574 - 0.1549i
this is a 3D matrix a.i want an inverse such that: inv (a(:,:,1)) inv (a(:,:,2)) inv (a(:,:,3)) and i want a single command that coulod do it or a code so that the answer is still in the form of a 3D matrix.

Answers (2)

Andrei Bobrov
Andrei Bobrov on 2 Aug 2013
Edited: Andrei Bobrov on 2 Aug 2013
a(:,:,1) =[-0.6044-0.1389i, -5.2117-32.3236i;-0.0019-0.0205i, -0.6058-0.1386i]
a(:,:,2) =[-0.5319-0.1475i, -4.6956-34.9899i;-0.0016-0.0213i, -0.5335-0.1473i]
a(:,:,3) =[-0.4557-0.1551i, -4.1408-37.3825i;-0.0014-0.0220i, -0.4574-0.1549i]
s = size(a);
e1 = eye(s(1:2));
for jj = s(3):-1:1
b(:,:,jj) = a(:,:,jj)\e1;
end
  2 Comments
padoh
padoh on 2 Aug 2013
ive entered the exact code in matlab n no output matrix b is generated and no error has occurred either
Jan
Jan on 2 Aug 2013
@padoh: Then use the debugger to step through the code line by line to find out, what's going own. It is a good idea to invest own effort when a problem is discussed in the forum. Do not wait for others to solve your problem.

Sign in to comment.


David Sanchez
David Sanchez on 2 Aug 2013
a=rand(2); % example matrix
b=inv(a) % inverse matrix
  3 Comments
padoh
padoh on 2 Aug 2013
the question is like this:
a(:,:,1) =
-0.6044 - 0.1389i -5.2117 -32.3236i
-0.0019 - 0.0205i -0.6058 - 0.1386i
a(:,:,2) =
-0.5319 - 0.1475i -4.6956 -34.9899i
-0.0016 - 0.0213i -0.5335 - 0.1473i
a(:,:,3) =
-0.4557 - 0.1551i -4.1408 -37.3825i
-0.0014 - 0.0220i -0.4574 - 0.1549i
this is a 3D matrix a.i want an inverse such that: inv (a(:,:,1)) inv (a(:,:,2)) inv (a(:,:,3)) and i want a single command that coulod do it or a code so that the answer is still in the form of a 3D matrix.
David Sanchez
David Sanchez on 2 Aug 2013
Maybe this is what you need:
A=rand(4,4,4);
B = zeros(size(A));
for k=1:size(A,3)
B(:,:,k) = inv(A(:,:,k));
end

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!