%
%   frf_median_filter.m  ver 1.1  January 22, 2013
%
function[signal_out]=frf_median_filter(a)
%
last=length(a);
bb=a;
%
w=3;  % window size use odd
%
k=round((w-1)/2.);
%
mid=(w+1)/2;
%
signal_out=zeros(last,1);
%
progressbar;
for i=1:last
    progressbar(i/last);
%
    c=zeros(w,1);
%
	jk=1;
%
	for j=(i-k+1):(i+k+1)
%	
		if(j>=0 && j<=last )
			c(jk)=a(j);
			jk=jk+1;
        end
%        
    end
%
	jk=jk-1;
%
    c=sort(c);
%
	signal_out(i)=c(mid);
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
end
pause(0.3);
progressbar(1);
%
signal_out(1)=a(1);