%
% program to back calculate Lagrangian position file into final format
%
% Uses the "fprintf" command inside a For-Loop to generate
% formatted data
%
% inputs are the x & y geographic displacement vectors of the
% ship and the drifter
%
load ag5b2.xyg;
load dg5b2.xyg;
xl=ag5b2(:,7)-dg5b2(:,7);
yl=ag5b2(:,8)-dg5b2(:,8);
%
fid = fopen('ag5b2.dat','w');
for i=1:length(xl);
fprintf(fid,'%7.4f %8.0f %5.0f %5.0f %8.4f %9.4f %9.4f %9.4f\n',...
 ag5b2(i,1),ag5b2(i,2),ag5b2(i,3),ag5b2(i,4),ag5b2(i,5),ag5b2(i,6),xl(i,:),yl(i,:));
end
fclose(fid)
