MATLAB: Fast matrix multiplication in loop

loopmatrix multiplication

Dear All,
I have two matrices with dimensions 3×3 and E6x3. I need to multiply each row of the latter with the former. It's like
a=rand(3,3);
b=(1000000,3);
for i=1:size(b,1)
c=a*b(i,:)';
end
However, this step takes hours to be done. I wonder if there is any faster way to do this.
Cheers.

Best Answer

a=rand(3,3);
b=rand(100,3);
n=size(a,2);
m=size(b,1);
c=zeros(m,n);
for i=1:size(b,1)
c(i,:)=a*b(i,:)';
end
%or simply
c=(a*b')'