Hi, I am creating a program with a for loop. As I have asked in another question I have learned to speed this process with vector and ok. But I would like to know why this thing happen.
Take this code:
A = zeros(1000,1000);
for k = 1:1000
for j = 1:1000
A(k,j)=E0*exp(-65*((k-500)^2+(j-500)^2)) *exp(-1i *6.5*((k-500)^2+(j-500)^2));
On my computer the first 500 k are really fast, then after about 500, it is very slow, almost 0.8 sec for one k. Why?