Efficient computation of products of matrix arrays
Hi,
while extending the identification toolbox I often run into the need to compute a 2d matrix with a 3d array. That is, assume A is [m x n]
, B is [n x o x p]
and I need to compute C(:,:,j)=A*B(:,:,j)
. Currently, I simply run a for loop (as p is dimension of parameters and hence not so large), i.e. the minimal matlab code looks like
for j=1:size(B,3)
C(:,:,j) = A*B(:,:,j);
end
Is there a more efficient way/trick to do so?