matlab - Elementwise multiplication of a matrix by a vector -


suppose have matrix a=rand(2,14,24) , vector x=10*ones(1,14)

i want element wise multiplication of , x, such b(i,j,k)=a(i,j,k)*x(j) j=1,2,..14. want able without running loop. efficient way in matlab?

you first use repmat tile x right number of times, element-wise multiplication.

repx = repmat(x, [size(a, 1), 1, size(a, 3)]); b = a.*repx; 

Comments