
function [yout,nan01]=nanfill(yin);
 
  nan01=zeros(size(yin));
  nan01(isnan(yin)==1)=1;
  
  recnum=1:length(yin);
  ind=find(isnan(yin)==0);

  yint=yin(ind);
  recnumt=recnum(ind);
  
      if numel(yint)>1
          yout=interp1(recnumt,yint,recnum,'linear','extrap');
      else
          yout=yin;
      end
      
