function y_ave = runAve(y_raw)
% Sample running average program.
%
% Created by C. S. Tritt (v. 1.0).
persistent n y_old y_v_old

if isempty(n)
    n = 1;
    y_ave = y_raw;
    y_old = y_raw;
elseif n == 1
    n = 2;
    y_ave = (y_old + y_raw)/2;
    y_v_old = y_old;
    y_old = y_raw;    
else
    y_ave = (y_v_old + y_old + y_raw)/3;
    y_v_old = y_old;
    y_old = y_raw;
end