%% Àç±Í½ÄÀ» ÀÌ¿ëÇÑ Æò±Õ ÇÊÅÍ
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Project : Averaging Filter Function (Recursion)
% Version : 1.00a
% Date : 2011.05.07
% Explanation : The Function of AF using Recursive equation
% Author : Yoon JaWoong
% CopyRight : MILab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function avg = AvgFilter(x)
persistent preAvg k
persistent Init_value
if isempty(Init_value)
k = 1;
preAvg = 0;
Init_value = 1;
end
alpha = (k - 1) / k;
avg = alpha*preAvg + (1 - alpha)*x;
preAvg = avg;
k = k + 1;