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
In addition to gnovice's answer, you can also replicate your vector along the other dimensions and do a direct element wise multiplication.
A=randn(1000,1000,3);%# this is your matrix
vector=[1,2,3];%# this is your vector
[dim1 dim2 ~]=size(A);
replicatedVector=repmat(reshape(vector,1,1,3),[dim1,dim2,1]);
out=A.*replicatedVector;