function [unew,vnew]=resamp(u,v,t,tnew);
%function [unew,vnew]=resamp(u,v,t,tnew);

for i=1:length(u)
    good=find(u(i,:)~=NaN);
    order=length(good)-4         %  7 points would be fit to a third order fn
    if order>0
       ucoefs=polyfit(t(i,good),u(i,good),order);
       unew(i,:)=polyval(ucoefs,tnew);
       vcoefs=polyfit(t(i,good),v(i,good),order);
       vnew(i,:)=polyval(vcoefs,tnew);
       bad=find(  (tnew<min(t(i,good))-.5)|(tnew>max(t(i,good))+.5)  );
       vnew(i,bad)=ones(1,length(bad))*NaN;
       unew(i,bad)=vnew(i,bad);  
    else
        unew(i,:)=ones(tnew)*NaN;
        vnew(i,:)=unew(i,:);
    end
    
end
