Clear Filters
Clear Filters

How to extract latitude and longitudes from a table given the timestamp range?

2 views (last 30 days)
Hello, I'm currently using a time table and want to have the user give a start time and end time then store them in variables. Once given, I want to use the timetiable to access a list of latitude and longitude values given in between those times and plot it. I'm still new to MATLAB and unsure how to approach this is ui.app designer.

Answers (2)

Cris LaPierre
Cris LaPierre on 13 Jun 2024
I would use isbetween to create an index of the table rows that are between the lower and upper times.
I would then use that index to extract the specific variable values I wanted from the table. See Accessing Data in Tables for this.

Steven Lord
Steven Lord on 13 Jun 2024
Use a timerange object as the row index into your timetable.
Time = datetime({'12/18/2015 08:00:00';'12/18/2015 10:00:0';'12/18/2015 12:00:00';...
'12/18/2015 14:00:00';'12/18/2015 16:00:00';'12/18/2015 18:00:00'});
Temp = [37.3;39.1;42.3;45.7;41.2;39.9];
TT = timetable(Time, Temp)
TT = 6x1 timetable
Time Temp ____________________ ____ 18-Dec-2015 08:00:00 37.3 18-Dec-2015 10:00:00 39.1 18-Dec-2015 12:00:00 42.3 18-Dec-2015 14:00:00 45.7 18-Dec-2015 16:00:00 41.2 18-Dec-2015 18:00:00 39.9
R = timerange('12/18/2015 09:00 AM', '12/18/2015 05:00 PM')
R =
timetable timerange subscript: Select timetable rows with times in the half-open interval: Starting at, including: 18-Dec-2015 09:00:00 Ending at, but excluding: 18-Dec-2015 17:00:00
TT(R, :)
ans = 4x1 timetable
Time Temp ____________________ ____ 18-Dec-2015 10:00:00 39.1 18-Dec-2015 12:00:00 42.3 18-Dec-2015 14:00:00 45.7 18-Dec-2015 16:00:00 41.2

Community Treasure Hunt

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

Start Hunting!