How to remove the horizontal line from my NMEA plot ?

3 views (last 30 days)
% 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

Accepted Answer

Star Strider
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
Yosuanto
Yosuanto on 20 Mar 2023
Hi! thanks for the answer
After checking the parsed GGA data I noticed that there are some segments of the file are set to NaN value
After deleting the row with NaN value
it become normal
Star Strider
Star Strider on 20 Mar 2023
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!