function [xout] = delete_singleton(xin)
% Set singletons equal to missing value code;
%
xout = xin;
n_2 = size(xin,2);
n_1 = size(xin,1);
for i = 1:n_2;
    ii = isnan(xin(:,i));
    if (ii(1) == 0) & (ii(2) == 1)
        xout(1,i)=NaN;
    end
    for t = 2:n_1-1;
      if ((ii(t) == 0) & (ii(t-1 )== 1)) & (ii(t+1) == 1)  
          xout(t,i)=NaN;
      end
    end;
    if (ii(end) == 0) & (ii(end-1) == 1)
        xout(end,i)=NaN;
    end
end;
end

