MATLAB: Efficient Row x Collumn multiplication

MATLABmultiplication

Hi all,
Consider the vectors: A of size; s x 4 B of size; 4 x s
Now, I am only interested in the product A(i,:)*B(:,i) of size s x 1
for i=1,..,s. I.e. only the row times the collumn with the same index.
The solution I found myself is: diag(A*B);
But I think there must be a faster solution, since I calculate many useless matrix elements if s>>4.
Do you guys have a suggestion?

Best Answer

sum(A'.*B)