MATLAB: Multiplying 3D matrices

3dmatrixmatrix multiply

To 3d-Matrix:
How can i multiplicate two 3d-Matrizes?
When i use following code:
A1=[1,2;3,4];
B1=[5,6;7,8];
C1=[9,10;11,12];
Z1=cat(3,A1,B1,C1)
A2=[1,2;3,4];
B2=[5,6;7,8];
C2=[9,10;11,12];
Z2=cat(3,A2,B2,C2)
Z=Z1*Z2
Then comes this Error:
Error using *
Arguments must be 2-D, or at least one argument must be scalar. Use TIMES (.*) for elementwise multiplication.
But when I use (.*), its the wrong multiplication, because its elementwise and i want a matrixmultiplication.
The result of the first array with .* is
Z(:,:,1) =
1 4
9 16
But it should be like
>> A1 * A2
ans =
7 10
15 22
Maybe someone can help.

Best Answer

There is no stock function (what a MATRIX LABORATORY doesn't have such feature?), but here it is MTIMESX