How to remove the horizontal line from my NMEA plot ?
1 view (last 30 days)
Show older comments
% Opens the file gpsLog.txt with read access.
fileID = fopen('gpsLog.txt','r');
% Read the text file.
gpsData = fscanf(fileID,'%c');
parserObj = nmeaParser('MessageId','GGA');
% Parse the NMEA Data.
ggaData = parserObj(gpsData);
% Initialize variables.
latVector = zeros(1,numel(ggaData));
lonVector = zeros(1,numel(ggaData));
for i=1:length(ggaData)
% Check if the parsed GGA sentences are valid and if they are valid, get the
% latitude and longitude from the output structures. Status = 0,
% indicates the data is valid
if ggaData(i).Status == 0
latVector(i) = ggaData(i).Latitude;
lonVector(i) = ggaData(i).Longitude;
end
end
% Remove Nan value in latitude and longitude data, if any. nmeaParser object
% returns NaN for a value if the value is not available in the sentence.
% For example, latitude and longitude data are not available if there is no
% satellite fix.
latVector = latVector(~isnan(latVector));
lonVector = lonVector(~isnan(lonVector));
% Plot the position in geographic coordinates
geoplot(latVector,lonVector,'Marker',"*",'MarkerSize',3, ...
"Color",'blue','MarkerFaceColor','red');
% Selects the basemap
geobasemap 'topographic';
this is the code from matlab website on how to plot NMEA log file

0 Comments
Accepted Answer
Star Strider
on 20 Mar 2023
With no file or other information, the problem may be that there is a common value (possibly 0) that separates segments of the file. Find out what that constant is, set it to NaN, and then use fillmissing or rmmissing to resolve the problem.
2 Comments
Star Strider
on 20 Mar 2023
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
More Answers (0)
See Also
Categories
Find more on Earth, Ocean, and Atmospheric Sciences in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!