nxp = 100; time_table=zeros(nxp,2); for ixp=1:nxp n=1000; k=100; m=1; x=randn(n,m); tic tmp = reshape(x,k,[],m); x_avg = reshape(mean(tmp),[],m); t1=toc; tic; h=floor(n/k); y=zeros(h,m); for ik=1:h tstart = (ik-1)*k+1; tstop = ik*k; y(ik,:)=mean(x(tstart:tstop,:)); end t2=toc; ratio_high=t1/t2; n=1000; k=100; m=randi(10); x=randn(n,m); tic tmp = reshape(x,k,[],m); x_avg = reshape(mean(tmp),[],m); t1=toc; tic; h=floor(n/k); y=zeros(h,m); for ik=1:h tstart = (ik-1)*k+1; tstop = ik*k; y(ik,:)=mean(x(tstart:tstop,:)); end t2=toc; ratio_low=t1/t2; time_table(ixp,:) = [ratio_high,ratio_low]; endfor mean(time_table) [std(time_table(:,1)),std(time_table(:,2))]