How to multiply two symbolic matrices fully?

4 views (last 30 days)
I need multiply 2 matrices:
syms epsXX1 epsXX2 epsXY1 epsXY2 epsYY1 epsYY2 epsZZ1 epsZZ2;
eps = [epsXX1 - 1i*epsXX2, epsXY1 - 1i*epsXY2, 0; ...
-(epsXY1 - 1i*epsXY2), epsYY1 - 1i*epsYY2, 0;
0, 0, epsZZ1 - 1i*epsZZ2;];
syms muXX1 muXX2 muXY1 muXY2 muYY1 muYY2 muZZ1 muZZ2;
mu = [muXX1 - 1i*muXX2, muXY1 - 1i*muXY2, 0; ...
-(muXY1 - 1i*muXY2), muYY1 - 1i*muYY2, 0;
0, 0, muZZ1 - 1i*muZZ2;];
eps * mu
Result is follow,
[ (epsXX1 - epsXX2*1i)*(muXX1 - muXX2*1i) - (epsXY1 - epsXY2*1i)*(muXY1 - muXY2*1i), (epsXY1 - epsXY2*1i)*(muXX1 - muXX2*1i) + (epsYY1 - epsYY2*1i)*(muXY1 - muXY2*1i, 0]
[ - (epsXX1 - epsXX2*1i)*(muXY1 - muXY2*1i) - (epsXY1 - epsXY2*1i)*(muYY1 - muYY2*1i), - (epsXY1 - epsXY2*1i)*(muXY1 - muXY2*1i) + (epsYY1 - epsYY2*1i)*(muYY1 - muYY2*1i), 0]
[0, 0, (epsZZ1 - epsZZ2*1i)*(muZZ1 - muZZ2*1i)]
but I need to get its in more simple form:
[(a + b + ..) + (a1 + b1 + ..)+1i, .., ..]
[(a + b + ..) + (a1 + b1 + ..)+1i, .., ..]
[(a + b + ..) + (a1 + b1 + ..)+1i, .., ..]
Is exist some ways to get this?

Accepted Answer

Andreas Apostolatos
Andreas Apostolatos on 5 Jun 2021
Hi Igor,
I understand that you are seeking to have the components of the resulting matrix from the multiplication expanded. You can use function 'expand' for your needs, see the following documentation page accordingly,
This way, the operation 'expand(eps*mu)' results in the following expanded expression,
[epsXX1*muXX1 - epsXX2*muXX2 - epsXY1*muXY1 + epsXY2*muXY2 - epsXX1*muXX2*1i - epsXX2*muXX1*1i + epsXY1*muXY2*1i + epsXY2*muXY1*1i, epsXX1*muXY1 - epsXX2*muXY2 + epsXY1*muYY1 - epsXY2*muYY2 - epsXX1*muXY2*1i - epsXX2*muXY1*1i - epsXY1*muYY2*1i - epsXY2*muYY1*1i, 0]
[epsXY2*muXX2 + epsXY1*muXX2*1i + epsXY2*muXX1*1i - epsXY1*muXX1 - epsYY1*muXY1 + epsYY1*muXY2*1i + epsYY2*muXY1*1i + epsYY2*muXY2, epsXY2*muXY2 + epsXY1*muXY2*1i + epsXY2*muXY1*1i - epsXY1*muXY1 + epsYY1*muYY1 - epsYY1*muYY2*1i - epsYY2*muYY1*1i - epsYY2*muYY2, 0]
[ 0, 0, epsZZ1*muZZ1 - epsZZ2*muZZ2 - epsZZ1*muZZ2*1i - epsZZ2*muZZ1*1i]
I hope this helps.
Kind regards,
Andreas

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!