
%==========================================================================
%
% Description: this function computes the moving average of all data input as an array
%
% Author: C. Alex Simpkins
%
% Date: Thurs Oct 5, 2006
%
% Inputs: array of data x, and window size a
%
% Outputs: filtered data xf
%
%==========================================================================

function xf=RLow_PassF07(x,a)

%this just does a basic error check to make sure our filter coefficient
%is within 0<=a<=1 (in other words we force the boundaries to be within [0,1]...
if a>1 
   a=1; 
elseif a<0,
   a=0; 
end

%pre-allocate the memory...
xf = zeros(1,length(x));

%set the first value, because our loop will start at the second value.
xf(1) = x(1);

%loop over all the data points...
for i=2:length(x),
    %the window loop...
    xf(i) = (1-a)*x(i) + (a)*xf(i-1);
end
%now our code will return to where it was called from...