line1 = sprintf('hh mm ss\tglat\tglon\tapex mlat\tapex mlon\tapex mlt\tSz\tPhi\tE(along)\tE(across)\n');

filename = 'AMIE_F13_2005_236.dat';
fid = fopen(filename,'wt');
fprintf(fid,line1);

for i = 1:length(dataA_13)
    k = find(~isnan(dataA_13(i,:)));
    if length(k) ~= 0
        hh = floor((i-1)/3600);
        left = (i-1) - 3600*hh;
        mm = floor(left/60);
        ss = (i-1) - 3600*hh - 60*mm;        
        fprintf(fid,'%02d %02d %02d   %10.5f   %10.5f   %10.5f   %10.5f   %10.5f   %10.5f   %10.5f   %15.5e   %15.5e\n',...
            hh,mm,ss,dataA_13(i,1),dataA_13(i,2),dataA_13(i,3),dataA_13(i,4),dataA_13(i,5),dataA_13(i,6),dataA_13(i,7),...
            dataA_13(i,8),dataA_13(i,9));
    end
end

fclose(fid)
