% Parse $GPGGA NMEA messages
i = 1; j= 1; bad = 0;
[fname, pname] = uigetfile('*.txt','Select file containing NMEA strings');
fileID = fopen([pname,fname],'r');
while ~feof(fileID)
line = fgetl(fileID);
switch line(1:6)
case '$GPGGA'
GPS{i} = textscan(line, '%s', 'Delimiter',',');
time(i) = myDateNum(GPS{i}{1}{2});
lat(i) = myStrLat(GPS{i}{1}{3},GPS{i}{1}{4});
lon(i) = myStrLon(GPS{i}{1}{5},GPS{i}{1}{6});
nsat(i) = str2double(GPS{i}{1}{8});
hdop(i) = str2double(GPS{i}{1}{9});
alt(i) = str2double(GPS{i}{1}{10});
i = i + 1;
case '$GPGSA'
GPS2{j} = textscan(line, '%s', 'Delimiter',',');
if (str2double(GPS2{j}{1}{3}) == 3)
time_vdop(j) = time(i-1);
vdop(j) = str2double(GPS2{j}{1}{17});
j = j + 1;
end
otherwise
bad = bad + 1;
% 'Line not in library'
end
end
yyaxis left
plot(time,alt)
title('GPS Altitude (m)')
xlabel('time (s)')
ylabel('Altitude MSL (m)')
yyaxis right
plot(time_vdop,vdop)
ylabel('Vertical DOP')
legend('MSL', 'VDOP')
% Zoom in on plot to determine the launch start time