"George " <georgew666@gmail.com> wrote in message <gminee$o3g$1@fred.mathworks.com>...
> Hello,
>
> Is there any way to realize vectorwise multiplication, just as elementwise multiplication does?
>
> In my case, there are two matrices: A1 (M x N), A2 (N X M). I want an M x 1 matrix, with element with an index k being the dot product of vectors A1(k, :) and A2(:, k). That is, the resultant matrix is a vector consisting the values on the diagonal of A1*A2. I do not want to use matrix multiplication followed by a diag() function, as it takes time to computer useless values, neither do I want to use loop. I think there is a way to mimic what we do with elementwise multiplication, which I would call vectorwise multiplication.
>
> Can anybody help me? Thanks.
Why not try
sum(A1.*A2.',2)
if you want a column vector result or
sum(A1'.*A2,1)
if you want a row vector result.
Roger Stafford
