MATLAB: Product of three 1d vectors and a 3d array

arrayMATLAB

Say I am given three n-dimesional vectors and an array T. Is there a way to compute the quantity without using a for loop?

Best Answer

aPermuted = a(:);
bPermuted = permute (b(:),[2,1,3]);
cPermuted = permute (c(:),[3,2,1]);
Z = T .* aPermuted .* bPermuted .* cPermuted;
Result = sum (Z,'all');
Related Question