The problem is this:
I have a set of 20 equations:
r1 = s1*h1_1 + s2*h1_2 + ... s20*h1_20
r2 = s1*h2_1 + ...
...
r20 = s1*h20_1 + ...
where r, s and h are matrices, and the symbol * denotes a pointwise product . It can be rewritten in matrix form R = H * S. I want to solve this equation for S - so I need to calculate inv (H) * R. But how can I calculate inv (H) if every element of H is a matrix? I can’t just combine these smaller matrices into a large matrix H, and then invert it, as this will give a different result than, for example. by inverting the matrix H with symbolic values, and then substituting these symbolic values with smaller matrices (due to the pointwise product present in the set of equations).
So far I have come up with 1 solution. I will create a matrix H with symbolic values of 20x20, I will invert it, and then I will evaluate each cell of the resulting inverted matrix using "subs".
H = sym('A',[20 20]);
invmat = inv(H) ;
% here I load 400 smaller matrices with appropriate names
invmat_11 = subs(invmat(1,1));
But the inversion of such a matrix is difficult to calculate on any middle-class computer, so I never managed to run this code. Do you know any other way to calculate the inverse of the matrix H - or directly solve for S?
They asked me a simple example: Consider the equation R = H * S (S is unknown). Let say H = [AB; CD], where A, B, C, D are 2x2 matrices, for example.
A = [A11 A12; A21 A22]
and R and S are 2x1 matrices, for example.
R = [R1;R2]
To calculate for S, I need to solve inv (H) * R, symbolically inv (H) =
[ -D/(B*C - A*D), B/(B*C - A*D)]
[ C/(B*C - A*D), -A/(B*C - A*D)]
Now I can replace A, B, C and D with real 2x2 matrices and calculate the inverse of H:
inv(H) = [H1 H2; H3 H4]
Where
H1 = -D/(B*C - A*D)
inv (H).
inv (H) R ( S):
S1 = H1*R1 + H2*R2
S2 = H3*R1 + H4*R2
, H1-H4 R1-R2 , * .