%
% program to extract specific times for Transcect Files
% from the master position file
%
% Uses the "fprintf" command inside a For-Loop to generate
% formatted data
%
% by using the "distxy.m" function to generate geographic displacements
%
load /home0/ftp/pub/gbs/apb2.dat;
init=input(' Enter the inital time in yeardays:');
endt=input(' Enter the end time in yeardays:');
tnum=input(' Enter the transect Number:');
%
% note we save this to use in the output file name
%
n=num2str(tnum);
n2=num2str(tnum);
%
n=pickout(apb2,1,init,endt,[1,2,3,4,5,6]);
%
% make a plot and ask user to reselect if desired
%
plot(n(:,6),n(:,5))
for il=1:length(n)/10:length(n);
lo=num2str(n(il,3));
text(n(il,6),n(il,5),lo);
end;
%
res=input('Do you want to reselect your time (y/n)?','s');
if res == 'y'
init=input(' Enter the inital time in yeardays:');
endt=input(' Enter the end time in yeardays:');
n=pickout(apb2,1,init,endt,[1,2,3,4,5,6]);
end;
%
% calculate the geographic displacements
%
lat = n(:,5);
lon = n(:,6);
[x,y]=distxy(lat,lon);
x=x';
y=y';
%
foutf=['at',n2,'b2.xyg'];
fid = fopen(foutf,'w');
for i=1:length(x);
d(i,:)=sqrt(x(i,:)*x(i,:)+y(i,:)*y(i,:));
fprintf(fid,'%7.4f %8.0f %5.0f %5.0f %8.4f %9.4f %6.2f %6.2f %6.2f\n',...
 n(i,1),n(i,2),n(i,3),n(i,4),n(i,5),n(i,6),x(i,:),y(i,:),d(i,:));
end
fclose(fid)
