function bad=wild(x,m,goplot)
%function bad=wild(x,m,[goplot])
%           Wild point editor. 
%           x is input array, m is a scaler multiplier for the standard dev.
%           of 5 point running mean above which points will be rejected.
%           bad is an index array of bad points
%           any value for goplot makes it plot the points (if there are
%              any bad ones
good=find(x~=NaN);
x=x(good);
xfilt=x-boxfilt(x,5);
%plot(xfilt)
%pause
cutoff=m*std(xfilt);
bad=find(abs(xfilt)>cutoff);
bad=good(bad);
if (nargin>2)&(length(bad)>0)
      a=1:length(x);
      plot(a,x,a(bad),x(bad),'x')
end

