How can I read a GPS Log from a *.txt File, separate the Strings and compare it do a different file

14 views (last 30 days)
Hello, I am currently trying to determine the accuracy of my GPS-module by comparing the log Data with the Data of a differential GPS with a high accurate tracking system. I have logged from the U-blox Neo Device into a *.txt File and the first thing I would like to do is to filter out the important data from the text file:
1) $GPRMC,092054.00,A,4850.54467,N,01043.20216,E,7.615,9.68,240516,,,A*6E
I only need this "4850.54467 N 01043.20216 E" info (if possible converted into latitude and longitude)
2) Is it possible do compare to values in Matlab and calculate an Average as well as the standard derivation? Is it possible to read out the *.txt file, separatate the important string form the others and then write it into a new file?

Accepted Answer

Star Strider
Star Strider on 4 Jun 2016
Edited: Star Strider on 4 Jun 2016
I don’t have your text file. I would use the textscan function to read it. It will allow you to read only the columns you want (probably best as numeric and strings for the value and direction). You can probably do that easily with a bit of experimentation.
This should get you started:
str = '$GPRMC,092054.00,A,4850.54467,N,01043.20216,E,7.615,9.68,240516,,,A*6E';
latlon = textscan(str, '%*s %*f %*s %f %s %f %s %*f %*f %*s', 'MultipleDelimsAsOne',1, 'Delimiter',',');
Result = sprintf('%.5f %s \t\t %.5f %s', latlon{1}, latlon{2}{:}, latlon{3}, latlon{4}{:})
Result =
4850.54467 N 1043.20216 E
You will have to experiment to get the result you want.
EDIT Forgot 2):
Yes, using the mean and std functions.
Writing to a new file is relatively straightforward. There are several options, including fprintf, csvwrite, xlswrite, save (for .mat files) and others. It depends on what you want to do. (The fprintf function works similarly to the sprintf call I used here, with similar results.) Also be sure to see the documentation on the fopen and fclose functions.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!