for i=1:length(v) %for each numer from 1 to length of arry
if(i==1) %1/1 = 1
cumavg(i)=v(i); else cumavg(i)=0; for j=1:i cumavg(i)=cumavg(i)+v(j); end cumavg(i)=cumavg(i)/i; end if(cumavg(i)<= (avg-0.01)) mark=i; endend
MATLAB: How to vectorize this loop
MATLABvectorization speed optimisation
Best Answer