MATLAB: Efficient Matrix Multiplication

efficient matrix multiplicationop_has_left_the_building

I have A(2000×5000). I need to perform the following:
P1 = A(:,1)*A(:,1)';
for i=2:5000
P1 = P1 + AA(:,i)*A(:,i)'
end
What is the most efficient way to do above? It takes so much time to do it right now due to size of the arrays.

Best Answer

P1 = A * A';
On my machine, that cut the execution time from 330 seconds to 1.5. :-)