필터 지우기
필터 지우기

3D Matrix Multiplication

조회 수: 59 (최근 30일)
Rahul Marwaha
Rahul Marwaha 2021년 2월 24일
댓글: Masoud Aminzadeh 2023년 8월 6일
Hi I have created two large matrices of which I have reshaped to create the following:
A = 3x1x4 double
B = 3x3x4 double
C = B * A ????
I was wondering how I could multiply each 3x3 matrix from B with each 3x1 matrix from A? The aim is to create a new 3x1x4 matrix in the end. Note: I don't have R2020b so don't have access to the pagemtimes function.
Any help is greatly appreciated, thanks!
  댓글 수: 1
Masoud Aminzadeh
Masoud Aminzadeh 2023년 8월 6일
use pagewise function

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

채택된 답변

the cyclist
the cyclist 2021년 2월 24일
편집: the cyclist 2021년 2월 24일
You can do it straightforwardly with a for loop:
% Some made-up input data
A = rand(3,1,4);
B = rand(3,3,4);
[mA,nA,pA] = size(A);
[mB,nB,pB] = size(B);
C = zeros(mB,nA,pA);
for np = 1:pA
C(:,:,np) = B(:,:,np) * A(:,:,np);
end
  댓글 수: 1
Rahul Marwaha
Rahul Marwaha 2021년 2월 25일
Thanks, that worked perfectly!

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2021년 2월 24일

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by