How to read an .SRT file in order to extract data ?

10 views (last 30 days)
I got data of a drone's position in an .srt file that I need to analyse. I'm attaching an example file in .txt format that shows how data is organized within.
I'm used to working with .csv files or other file formats that have some very simple delimeter to set every variable apart. However, I'm struggling with figuring out what functions should I use to read this.
I simply need to be able to extract the GPS coordinates of the drone's position. In the file, the lines where that data is located looks like this:
00:00:08,000 --> 00:00:09,000
HOME(-68.8723,-46.0144) 2022.01.01 11:11:11
GPS(-63.7521,-43.1158,14) BAROMETER:15.0
ISO:100 Shutter:1000 EV:+1 Fnum:2.2
I'd need to extract the data that's located inside of GPS(...) and create Nx2 matrix that holds all the GPS coordinates of the file, where N is the number of data points.
Later on I might need to incorporate more data such as the Barometer info, but I think that if I could get some help in figuring out this part I could figure the rest out myself.

Accepted Answer

Mathieu NOE
Mathieu NOE on 4 Jan 2022
hello Elias
try this, hope it helps
%% read one file
filename = 'EXAMPLE.txt';
a = readlines(filename);
% find GPS (and barometer) data
GPS_indexes = find(contains(a,'GPS'));
for ci = 1:length(GPS_indexes)
STR = char(a(GPS_indexes(ci)));
ind1 = findstr(STR,"(");
ind2 = findstr(STR,")");
GPS_data(ci,:) = str2num(STR(ind1+1:ind2-1));
% barometer data (on same row as GPS data)
ind3 = findstr(STR,":");
barometer_data(ci,:) = str2num(STR(ind3+1:end));

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!