Consider two matrices A and B defined by
A=rand(10,3);B=rand(3,10);
I'm interested in multiplying the vectors defined the first, second, and third rows in B by the vectors defined the first, second, and third columns in A, respectively. My intent is to generate ten, 3X3 matrices defined by
Matrix1= B(:,1)*A(1,:) Matrix2= B(:,2)*A(2,:)...Matrix10= B(:,10)*A(10,:)
My initial thought was something like
B(:,1:10)*A(1:10,:)
but this approach populates the matrices B and A prior to multiplication, yielding a single 3X3 matrix. How to I change the "order-of-operations" if you will—call each vector on a term-by-term basis, multiplying in between each call to generate the desired matrix? Of course, I really want to avoid having to use for loops.
Best Answer