adding gps data from one file to another
Show older comments
I am using an underway system on a research vessel and the GPS logger was left ashore. DOH! So I would like to use the GPS from the ship data. However the ship GPS is logged every 10 seconds where my underway system logs every 1.5 minutes. Is there a way to have matlab look at both files, grab the gps data to the corresponding date and time in my underway log file, and then write the correct gps to the underway log file?
I am a novice user with matlab and have looked into the import feature, but I am not sure this is the write way to go. The underway file is an excel csv and the gps file from the ship is a .GPS file. Thanks in advance for any and all help.
Mike
Answers (1)
Star Strider
on 19 Aug 2015
Once you get the GPS data available to you, with the appropriate time stamps, I would first convert all the time stamps to datenum date numbers, and if necessary convert degrees-minutes-seconds latitude and longitude data to degrees and decimal degrees, then use the interp1 function.
For example,
Ship_GPS = [time lat lon]; % Assume Column Vectors
Underway_System [time other_data]; % Assume Column Vectors
Underway_GPS = interp1(Ship_GPS(:,1), Ship_GPS(:,2:3), Underway_System(:,1), 'linear', 'extrap');
You may not need the 'extrap' option, but it’s better to include it, especially if you have a lot of data and your routine will take a while to run.
You can then concatenate the interpolated ‘Underway_GPS’ (Nx2) matrix with your other ‘Underway_System’ data matrix.
This is quite obviously untested code, but it should work.
2 Comments
Mike
on 19 Aug 2015
Walter Roberson
on 19 Aug 2015
A column vector is a 2D array that has only 1 column. A row vector is a 2D array that has only 1 row.
What form is the data stored in at the moment? It might not be necessary to save it as excel. MATLAB would not require column headers as long as you are consistent about which column is which.
You could use a xls or csv file that had a text date and time, then the latitude, then the longitude. Decimal degrees would be easiest for latitude and longitude.
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!