function unew=cleanall(u);
%function unew=cleanall(u);
%                           linear interpolation to fill all points 
%                           with NaN
[ilen,jlen]=size(u);
u=clean2(u(:));

bad=find(u==NaN);
if length(bad)>0
   badpoints=length(bad)
  if bad(1)==1 
        bad(1)=[];
  end
end
if length(bad)>0  
  if bad(length(bad))==length(u) 
       bad(length(bad))=[];
  end
  dbjump=find(diff(bad)>1);
  if length(dbjump)>0
      lastgood=bad(find(diff(bad)>1)+1)-1;
      nextgood=bad(find(diff(bad)>1))+1;
      lastgood(2:length(lastgood)+1)=lastgood;
      lastgood(1)=bad(1)-1;
      nextgood(length(nextgood)+1)=bad(length(bad))+1;
  elseif length(bad)>0
      lastgood=bad(1)-1;
      nextgood=bad(length(bad))+1;
  end
  segments=length(lastgood)
  for i=1:length(lastgood)
     fix=lastgood(i)+1:nextgood(i)-1;
     fac=(nextgood(i)*ones(fix/fix(1))-fix)/(nextgood(i)-lastgood(i));
     u(fix)=u(lastgood(i))*fac+u(nextgood(i))*(ones(fac/fac(1))-fac);
  end
end
unew=remat(u,ilen);

