Resample and Aggregate Data in Timetable
This example shows how to resample and aggregate data in a timetable. A timetable is a type of table
that associates a time with each row. A timetable can store column-oriented data variables that have
different data types and sizes, provided that each variable has the same number of rows. With the
retime function, you can resample timetable data, or aggregate timetable data into time bins you
specify.
Import Timetable
Load a timetable containing weather measurements taken from November 15, 2015, to November 19,
2015. The timetable contains humidity, temperature, and pressure readings taken over this time
period.
load outdoors
outdoors(1:5,:)
ans=5×3 timetable
Time
Humidity
TemperatureF
PressureHg
___________________
________
____________
__________
2015-11-15 00:00:24
49
51.3
29.61
2015-11-15 01:30:24
48.9
51.5
29.61
2015-11-15 03:00:24
48.9
51.5
29.61
2015-11-15 04:30:24
48.8
51.5
29.61
2015-11-15 06:00:24
48.7
51.5
29.6
Determine if the timetable is regular. A regular timetable is one in which the differences between all
consecutive row times are the same. outdoors is not a regular timetable.
TF = isregular(outdoors)
TF = logical
0
Find the differences in the time steps. They vary between half a minute and an hour and a half.
dt = unique(diff(outdoors.Time))
dt = 3x1 duration
00:00:24
01:29:36
01:30:00
Resample Timetable with Interpolation
Adjust the data in the timetable with the retime function. Specify an hourly time vector. Interpolate
the timetable data to the new row times.
TT = retime(outdoors,'hourly','spline');
TT(1:5,:)
ans=5×3 timetable
Time
Humidity
TemperatureF
PressureHg
___________________
________
____________
__________
Resample and Aggregate Data in Timetable
10-5
Précédent

- 451/1450

Suivant