필터 지우기
필터 지우기

Fastest way to multiply each block of an array with another matrix

조회 수: 1 (최근 30일)
Mnr
Mnr 2015년 12월 23일
댓글: Mnr 2015년 12월 23일
Hello all,
I have a 12x4xN array which I would like to multiply each 12x4 block by a 4x16 matrix in order to get a 12x16xN array. Could somebody please help me with a fast way of doing that? Thank you!

채택된 답변

James Tursa
James Tursa 2015년 12월 23일
편집: James Tursa 2015년 12월 23일
If you have a C compiler:
A = your 12 x 4 x N array;
B = your 4 x 16 matrix;
out = mtimesx(A,B);
You can find mtimesx here:
If you don't have a C compiler, then you can try MULTIPROD:
  댓글 수: 1
Mnr
Mnr 2015년 12월 23일
Thank you! I did it using mltiprod and it is perfect. Can I know what is the best way to install the C compiler as well?

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

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2015년 12월 23일
Let A - your array with size [12x4xN]
B - matrix 4x16
sa = size(A);
sb = size(B);
out = zeros([sa(1),sb(2),sa(3)]);
for jj = 1:sa(3)
out(:,:,jj) = A(:,:,jj)*B;
end

카테고리

Help CenterFile Exchange에서 Data Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by