%    
%   peak_filter_complex.m  ver 1.0  January 22, 2012
%
function[x]=peak_filter_complex(x)
%
last=length(x);
%
c=zeros(10,1);
%
progressbar;
for i=1:last-9
        progressbar(i/(last-9));
%
%       samples
%
        c=(x(i:(i+9)));
%
%       sort
%
        c=sort(c);
%        
%       remove highest value
%
        c(10)=[];
%
        ave=mean(c);
        sd=std(c);
        limit=abs(10*c(9));
%        
        for j=i:(i+9)
            if(abs(x(j))>limit)
                x(j)=c(9);
            end
        end
%
end
%
pause(0.2);
progressbar(1);