function[] = bdjkmlwrite( outFile,lat,lon,gps_t)

%function[] = bdjkmlwrite( outFile,lat,lon,gps_t)

ofile = strcat(outFile,'.kml');
outFID = fopen(ofile,'w');

%print header
fprintf(outFID,'<?xml version="1.0" encoding="utf-8"?>\n');
fprintf(outFID,'<kml xmlns="http://www.opengis.net/kml/2.2">\n');
fprintf(outFID,'<Document>\n');
fprintf(outFID,'   <name>%s</name>\n',outFile);

for i = 1:1:size(lat,1)
    fprintf(outFID,'     <Placemark>\n       <Snippet maxLines="0"> </Snippet>\n       <description> </description>\n');
    fprintf(outFID,'       <name>%04d</name>\n',str2double(gps_t(i,1)));
    fprintf(outFID,'          <Point><coordinates>%f,%f,0</coordinates></Point>\n',lon(i,1),...
                    lat(i,1));
    fprintf(outFID,'     </Placemark>\n');
end

fprintf(outFID,'</Document>\n</kml>\n');

fclose(outFID);
