MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
As an alternative, you can synchronize the timetables to a time vector that specifies half-
hour intervals.

tv = [datetime(2015,11,15):minutes(30):datetime(2015,11,18)];
tv.Format = indoors.Time.Format;
ttHalfHour = synchronize(indoors,outdoors,tv,'linear');
ttHalfHour(1:5,:)

ans=5×6 timetable
Time Humidity_indoors AirQuality Humidity_outdoors TemperatureF PressureHg
___________________ ________________ __________ _________________ ____________ __________

2015-11-15 00:00:00 36 80 49 51.299 29.61
2015-11-15 00:30:00 36 80 48.967 51.366 29.61
2015-11-15 01:00:00 36 80 48.934 51.432 29.61
2015-11-15 01:30:00 36.224 79.776 48.9 51.499 29.61
2015-11-15 02:00:00 36.634 79.366 48.9 51.5 29.61

Synchronize and Aggregate Data Values

Synchronize the timetables and calculate the daily means for all variables in the output
timetable.

ttDaily = synchronize(indoors,outdoors,'daily','mean');
ttDaily

ttDaily=4×6 timetable
Time Humidity_indoors AirQuality Humidity_outdoors TemperatureF PressureHg
___________________ ________________ __________ _________________ ____________ __________

2015-11-15 00:00:00 36.5 80.05 48.931 51.394 29.607
2015-11-16 00:00:00 36.85 80.35 47.924 51.571 29.611
2015-11-17 00:00:00 36.85 79.45 48.45 51.238 29.613
2015-11-18 00:00:00 NaN NaN 49.5 50.8 29.61

Synchronize the timetables to six-hour time intervals and calculate a mean for each
interval.

tt6Hours = synchronize(indoors,outdoors,'regular','mean','TimeStep',hours(6));
tt6Hours(1:5,:)

ans=5×6 timetable
Time Humidity_indoors AirQuality Humidity_outdoors TemperatureF PressureHg

10 Timetables

Free download pdf