function value = ave(T, V=T, t1=0, t2=NaN)

  if ( T == V )
    value = sum(T) / length(T);
    return
  endif

  n1 = point(T, t1);
  n2 = point(T, t2);
  sum = 0;
  
  for i = n1 : n2
    sum = sum + V(i);
  endfor
  
  value = sum / (n2 - n1 + 1);
  
endfunction
