MATLAB: How to vectorize this

loopsMATLABoptimizationspeedvectorization

It seems I dont understand sth about vectorization.
Aj = zeros(1, jCount); % it is filled in reality, but here I just swoh the size
uj = zeros(K, jCount); % as above
for angle = 1:K
currentUj = uj(angle, :);
beta(angle) = sum(Aj.*currentUj);
end
Can somebody show me how to vectorize this, so I can learn what I do wrong?
Best regards, Alex

Best Answer

This does that same as your loop:
beta = sum(bsxfun(@times,Aj,uj),2).';