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

matrixmultiple

Hello all,
I have a 12x4xN array which I would like to multiply each 12×4 block by a 4×16 matrix in order to get a 12x16xN array. Could somebody please help me with a fast way of doing that? Thank you!

Best Answer

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:
Related Question