function [rs,Y,Er] = dropw(rs,Y,Er,t);

L = length(rs);
if t == 1
   if abs(Er(1)-Er(2)) < abs(Er(L-1)-Er(L))
      I = 1;
      Er = -Er;
   else
      I = L;
   end
   rs(I) = []; Y(I) = []; Er(I) = []; L = L - 1;
elseif rem(t,2)==0
   [temp,k] = min(diff((Er(:))').*((-1).^(1:L-1)));
   if (k==1)|(k==L-1)
      [rs,Y,Er] = dropw(rs,Y,Er,1);
      [rs,Y,Er] = dropw(rs,Y,Er,t-1);
   else
      I = k;
      rs(I) = []; Y(I) = []; Er(I) = []; L = L - 1;
      rs(I) = []; Y(I) = []; Er(I) = []; L = L - 1;
      if t>2
         [rs,Y,Er] = dropw(rs,Y,Er,t-2);
      end
   end
elseif rem(t,2)==1
   [rs,Y,Er] = dropw(rs,Y,Er,1);
   [rs,Y,Er] = dropw(rs,Y,Er,t-1);
else
   disp('This statement should never be printed')
   keyboard
end

