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.

 채택된 답변

Bruno Luong
Bruno Luong 2019년 8월 20일

0 개 추천

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

댓글 수: 2

Aj
Aj 2019년 8월 20일
Thats really bad, but thanks. But I dont know, how to use MTIMESX. I read it and i dont understand it. Can you explain me, how I can use it, maybe with my example. That would be awesome
Bruno Luong
Bruno Luong 2019년 8월 20일
편집: Bruno Luong 2019년 8월 20일
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=mtimesx(Z1,Z2) % HERE IT IS, SO SIMPLE
Z1(:,:,1) =
1 2
3 4
Z1(:,:,2) =
5 6
7 8
Z1(:,:,3) =
9 10
11 12
Z2(:,:,1) =
1 2
3 4
Z2(:,:,2) =
5 6
7 8
Z2(:,:,3) =
9 10
11 12
Z(:,:,1) =
7 10
15 22
Z(:,:,2) =
67 78
91 106
Z(:,:,3) =
191 210
231 254
>>

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

질문:

Aj
2019년 8월 20일

편집:

2019년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by