how to find the inverse of a 2x2xm matrix?
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (2개)
Andrei Bobrov
2013년 8월 2일
편집: Andrei Bobrov
2013년 8월 2일
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
Jan
2013년 8월 2일
@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.
David Sanchez
2013년 8월 2일
a=rand(2); % example matrix
b=inv(a) % inverse matrix
댓글 수: 3
David Sanchez
2013년 8월 2일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!