function [unew,vnew]=tidesam2(ucoef,vcoef,tnew);
%function [unew,vnew]=tidesam2(ucoef,vcoef,tnew);
%         uses regression analysis (with mean, M2, M4 and M6) to generate
%		resampled timeseries using time array tnew;
%             Leaves out mean
[imax,jmax]=size(ucoef);
unew=[];
vnew=[];
choice=input('choice [2 4 6] or [2] etc.');
choice=choice/2;
period=[12.42 6.21 4.14];
freq=2*pi*ones(period)./period;
i=1:imax;
im=sqrt(-1);

unew(i,:)=zeros(length(ucoef),length(tnew));
vnew(i,:)=unew(i,:);

for j=choice
     unew(i,:)=unew(i,:)+real((ucoef(i,j*2)+im*ucoef(i,j*2+1))*..
                                           exp(-im*freq(j)*tnew));
     vnew(i,:)=vnew(i,:)+real((vcoef(i,j*2)+im*vcoef(i,j*2+1))*..
                                           exp(-im*freq(j)*tnew));
end
