%           tidevel2.m
%                    uses tidecoef to make tide coeficients for 
%                             a bunch of vel bins
istart=input('gh file # to start with ');
iend=input('gh file # to end with ');
tnew=5:18;
for i=istart:iend
	eval(concat('load gh',int2str(i),'vel.bin'));           % load raw
	eval(concat('load gh',int2str(i),'nav.bin'));              % load cal file

%                         clean out all bad points
	tbin=cleanall(tbin);
	u0bin=cleanall(u0bin);
	v0bin=cleanall(v0bin);

%                              run tidecoef
	  [u0coef,v0coef]=tidecoef(u0bin,v0bin,tbin);
%                              run tidesamp
	  [u0new,v0new]=tidesamp(u0coef,v0coef,tnew);
%                             save everything
	eval(concat('save gh',int2str(i),'cof.tid date u0coef v0coef'))
	eval(concat('save gh',int2str(i),'vel.tid date u0new v0new tnew'))
     disp(concat('saved gh',int2str(i),'cof.tid and ...vel.tid'))
end
