Modify data file timestamp, import text file

1 view (last 30 days)
I am starting with a text file with over 100 lines of: [3331 10 30.3861637 -86.36856 -28.7021 2011-04-30T17:17:21Z]
This is: [line number, segment number, latitude, longitude, elevation, timestamp]
I want to read the file into Matlab and: a) break out the lat, long, elev and time stamp into one matrix b) convert the timestamp from the odd 2011-04-30T17:17:21Z into just a the zulu time, and for some of the data add one hour c) just keep the lines of data with time steps at 5 second intervals, i.e. 05, 10, 15, 20, etc
Please help, I read the date/time files on mathworks website, but that is way above my ability right now and tight on time.
Thanks, Brian

Accepted Answer

Walter Roberson
Walter Roberson on 1 May 2011
fid = fopen(YourFileName, 'rt');
indata = textscan(fid, '%*f%*f%f%f%f%s');
fclose(indata);
lats = indata{1};
longs = indata{2};
evels = indata{3};
tstampc = char(indata{4});
tstampc = tstampc(:,end-8:end-1);
%now it is just the times
is5sec = ismember(tstampc(:,end),'05');
lats5 = lats(is5sec);
longs5 = longs(is5sec);
evels5 = evels(is5sec);
tstamp5 = tstampc(is5sec,:);
  2 Comments
Brian
Brian on 1 May 2011
Wow, I'm impressed by your logic there, stuff I would have never thought of nor knew those tricks. Thanks a lot for your help!
-Brian
Walter Roberson
Walter Roberson on 1 May 2011
Note that this code does not attempt to select the first sample within each 5 second slot: it selects exactly the samples whose times end in 0 or 5.

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!