// CALCULATE VARIANCE OVER LAST N POINTS Ni = 1000; Nj = 10; Nk = 10; A = rand(Ni,Nj,Nk); tic(); t0 = getdate(); N = 10; for k=1:Nk, for j=1:Nj, for i=N:Ni, B(i-(N-1),j,k) = ( mean(A(i-(N-1):i,j,k)) )^2; // Meansquare over last N points C(i-(N-1),j,k) = mean( A(i-(N-1):i,j,k).^2 ) ; D(i-(N-1),j,k) = B(i-(N-1),j,k) - C(i-(N-1),j,k) ; // Variance of over last N points end end end t1 = getdate(); toc(); dt = etime(t1,t0); disp(dt);