function zz=A_WinMean1D(in_signal,N,alpha); %***************************************************************** %* * %* THIS IS THE MATLAB IMPLEMENTATION OF THE ALPHA-WINSORIZED * %* TRIMMED MEAN FILTER FOR 1 DIMANSIONAL SIGNALS. * %* * %*===============================================================* %* * %* SINTAX: A_WinMean1D(in_signal,N,alpha); * %* * %* -'in_signal' - is the input signal to be filtered; It * %* should be a row vector; * %* -'N' - is the length of the filter. It should * %* be an odd number; * %* -'alpha' - alpha*N is the number of coefficients * %* from both sides of the input vector * %* that are replaced. It should be given * %* as a ratio (example 3/11 if the length * %* of the filter is N=11. This mean that 3* %* samples from each side of the input * %* sequence are replaced * %* (alpha*N<=(N-1)/2)); * %* * %*---------------------------------------------------------------* %* * %* AUTHOR: Radu Ciprian Bilcu * %* bilcu@cs.tut.fi * %* Tampere University of Technology * %* Signal Processing Laboratory * %* * %***************************************************************** iter=length(in_signal);%COMPUTE THE LENGTH OF THE INPUT SIGNAL for i=(N+1)/2:(iter-(N-1)/2)%START FILTERING THE SIGNAL xin=in_signal((i-(N-1)/2):(i+(N-1)/2));%STORE THE N SAMPLES FROM THE SIGNAL IN THE VECTOR xin xsort=sort(xin);%SORT THE INPUT SAMPLES xsort(1:alpha*N+1)=xsort(alpha*N+1).*ones(1,alpha*N+1);%REPLACE THE FIRST alpha*N SAMPLES %FROM THE BEGINNING OF THE INPUT VECTOR xsort(N-alpha*N:N)=xsort(N-alpha*N).*ones(1,alpha*N+1);%REPLACE THE LAST alpha*N SAMPLES %FROM THE END OF THE INPUT VECTOR out(i)=mean(xsort);%AVERAGE THE SAMPLES FROM THE INPUT VECTOR end figure%PLOT THE INPUT SIGNAL plot(in_signal); title('The input signal'); grid; figure%PLOT THE FILTERED SIGNAL plot(out); title('The filtered signal'); grid;