All pastes #1071497 Raw Edit

maverage.m

public text v1 · immutable
#1071497 ·published 2008-07-14 05:36 UTC
rendered paste body
function y = maverage(x, t, n)
if(size(x,1)==1)
  x=x';
endif
z1 = [0; cumsum(x)];
z2 = ( z1(n+1:t+1) - z1(1:t-n+1) ) / n;
y = [zeros(n-1,1); z2];