This bothers me a bit:
Suppose you have a matrix with three layers.
Is there a simple way to multiply this matrix with a vector of three elements so that the
One very terse solution is to reshape vector into a 1-by-1-by-3 matrix and use the function BSXFUN to perform the element-wise multiplication (it will replicate dimensions as needed to match the sizes of the two input arguments):
vector
newMatrix = bsxfun(@times,matrix,reshape(vector,[1 1 3]));