MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Combine Timetables and Synchronize Their Data


You can combine timetables and synchronize their data in a variety of ways. You can
concatenate timetables vertically or horizontally, but only when they contain the same
row times or timetable variables. Use the synchronize function to combine timetables
with different row times and timetable variables. synchronize creates a timetable that
contains all variables from all input timetables. It then synchronizes the data from the
input timetables to the row times of the output timetable. synchronize can fill in
missing elements of the output timetable with missing data indicators, with values copied
from their nearest neighbors, or with interpolated values. synchronize also can
aggregate timetable data over time bins you specify.

Concatenate Timetables Vertically

Load timetables from openPricesSmall and concatenate them vertically. The timetables
are opWeek1 and opWeek2. They contain opening prices for some stocks during the first
and second weeks of January 2016.

load openPricesSmall

Display the two timetables.

opWeek1

opWeek1=5×3 timetable
Time AAPL FB
____________________ ______ ______

08-Jan-2016 09:00:00 98.55 99.88
07-Jan-2016 09:00:00 98.68 100.5
06-Jan-2016 09:00:00 100.56 101.13
05-Jan-2016 09:00:00 105.75 102.89
04-Jan-2016 09:00:00 102.61 101.95

opWeek2

opWeek2=5×3 timetable
Time AAPL FB
____________________ ______ ______

14-Jan-2016 09:00:00 97.96 95.85
13-Jan-2016 09:00:00 100.32 100.58
12-Jan-2016 09:00:00 100.55 99

Combine Timetables and Synchronize Their Data
Free download pdf