N=100000000; x=rand(N,1); tic sumx=0; for i=1:N sumx=sumx+x(i); end my_mean=sumx/N toc tic matlab_mean=mean(x) toc