A 1D vector of size [1, 1, 3] (your B(1, 1, :)) is not the same size as a 1D vector of size [1, 3, 1] (your k), even though they have the same number of elements. You either need to squeeze the singleton dimensions out of your B vector, permute the dimensions of k, or reshape either: squeeze(B(1,1,:) .* k'
B(1, 1, :) .* permute(k, [1 3 2])
reshape(B(1, 1, :), 1, []) .* k
B(1, 1, :) .* reshape(k, 1, 1, [])
Best Answer