%           tideva.m
%                    uses tidecoef to make tide coeficients for 
%                             a bunch of vel bins

fprefix=input('file prefix for velocity (in quotes) ');

eval(concat('load ',fprefix,'va.bin'));           % load raw
eval(concat('load ',fprefix,'nav.bin'));              % load cal file

for i=1:5

ubin=remat(uabin(:,i),nrow);
vbin=remat(vabin(:,i),nrow);

ubin=cleanall(ubin);
vbin=cleanall(vbin);
tbin=cleanall(tbin);

[ucoef,vcoef]=tidecoef(ubin,vbin,tbin);
uacoef(:,i)=ucoef(:);
vacoef(:,i)=vcoef(:);
ell=ellrun(ucoef,vcoef,2);
ella(:,i)=ell(:);

end

eval(concat('save ',fprefix,'va.tid date uacoef vacoef ella'));  


