function averagearray=movingaverage(inputarray,MAstep)
%Function to produce a moving average of a one dimensional array
%syntax: averagearray=movingaverage(inputarray,MAstep)
%where input array is the input data, averagearray is the data 
%with a moving average of length MAstep applied to it.
%P.S.Bell 4/5/2001

sizeinput=size(inputarray);

lengthinput=length(inputarray);
lengthoutput=fix(lengthinput/MAstep);

if sizeinput(1)==1
    averagearray=zeros(1,lengthoutput);
elseif sizeinput(2)==1
    averagearray=zeros(lengthoutput,1);
end

for index=1:lengthoutput
    averagearray(index)=mean(inputarray(((index-1)*MAstep+1):index*MAstep));
end