How to use only GPGGA strings from a .csv file?

6 ビュー (過去 30 日間)
Balint Egri
Balint Egri 2020 年 12 月 9 日
回答済み: Shiva Kalyan Diwakaruni 2020 年 12 月 14 日
Hi guys,
I feel a bit stupid because Im asking this eventough I solved it for strings already. I have a.csv file with NMEA data which is 5 row / sample. I only want to use the 'GPGGA' strings from them. This is what I did so far:
% Load all GPS data
[~, raw_gps] = xlsread('20201110_GPSall.csv');
if strfind('$GPGGA') == 1
gps_data = split(raw_gps,',');
end
and I get an error the 'Not enough input arguement'. I think it is because I use xlsread and strfind cant search in xls file. Can someone tell me which command I should use to find only the 'GPGGA' ones?
Thank you very much in advance for any help:)

回答 (1 件)

Shiva Kalyan Diwakaruni
Shiva Kalyan Diwakaruni 2020 年 12 月 14 日
Hi,
You can try using csvread or textscan
example -
1) data=csvread('yourfile.csv');
if strfind('$GPGGA') == 1
gps_data = split(raw_gps,',');
end
2) fields=textscan(FileId,'%s','delimiter',',')
if ~isempty(find(strcmp(fields{1}(1), '$GPGGA'),1))
gps_data = split(raw_gps,',');
end
Hope it helps.

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by