对于第一个功能:
B = bsxfun(@times, A, nv);
对于第二个:
B = sum(bsxfun(@times, A, reshape(u, [size(u,1) size(u,2) 1 size(u,3)])), 4);