MATLAB: How to reduce For loop execution time

execution-timefor loop

I have following Matlab code to calculate summation of exponential summation term:
This code takes approx. 600 seconds to give final output s. Is there any way to reduce this computation time?
sum1 = 0;
s = 0;
for i=1:1000000000
for j=1:3
sum1 = sum1+(i*proc(j))^2;
end
s = s+exp(-sum1);
end

Best Answer

>> tic;s = sum(exp(-sum((reshape(proc(1:3), [], 1) * (1:1000000000)).^2))); toc
Elapsed time is 55.136908 seconds.
This was slowed down a fair bit because I ran out of memory and it started to swap. On my system, if I had run it in 10 sections of 1E8 the time would have been less than 20 seconds.