How can I extract data from the gps log?

1 Ansicht (letzte 30 Tage)
Joni Smith
Joni Smith am 16 Jul. 2021
Beantwortet: Simon Chan am 16 Jul. 2021
Hi! I have a log file with data from the gps:07.07.2021.txt. I need to upload it to matlab and sort the data. Take the data from the line $GPRMC and first write the time north east ( by example: 210113 5101.8327 15042.9328). Which function is the best way to do this?

Antworten (1)

Simon Chan
Simon Chan am 16 Jul. 2021
Is it ok the result in a cell array?
If yes, you may try the following:
Noticed that some of your data does not have the second and third parameters.
clear; clc;
rawdata = readcell('07.07.2021.txt');
idx = cellfun(@(x) contains({x},{'GPRMC'}),rawdata(:,1));
GPRMC_rawdata = rawdata(idx);
GPRMC_data = cellfun(@(x) strsplit(x,',','CollapseDelimiters',false),GPRMC_rawdata,'UniformOutput',false);
Data1 = cellfun(@(x) x(2),GPRMC_data);
Data1 = extractBefore(Data1,'.');
Data2 = cellfun(@(x) x(4),GPRMC_data);
Data3 = cellfun(@(x) x(6),GPRMC_data);
Result = cellfun(@(x,y,z) cat(2,x,' ',y,' ',z),Data1,Data2,Data3,'UniformOutput',false)
Result like this:
Result(1:10)
ans =
10×1 cell array
{'210113 5101.8327 15042.9328'}
{'210114 5101.8338 15042.9305'}
{'210115 5101.8356 15042.9226'}
{'210116 5101.8348 15042.9301'}
{'210117 5101.8344 15042.9306'}
{'210118 5101.8345 15042.9330'}
{'210119 5101.8338 15042.9338'}
{'210120 5101.8339 15042.9283'}
{'210121 5101.8335 15042.9319'}
{'210122 5101.8339 15042.9327'}

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by