Combine Timetable's

30 views (last 30 days)
Ioannis Tsikriteas
Ioannis Tsikriteas on 8 Sep 2018
Hi, i want to combine two timetables (9 column's) based the time.
The timetables has the same type of measurements with different time and i want to combine them into 1 timetable but when i use the 'synchronize' function i get a timetable with 18 columns!
I just want the second matrix (the one with the dates after the first one) to be added below of the dates of the first Timetable

Answers (1)

Peter Perkins
Peter Perkins on 12 Sep 2018
Perhaps
tt12 = [tt1; tt2]
i.e., just like any other MATLAB array.
  3 Comments
Steven Lord
Steven Lord on 17 Sep 2018
Concatenation with [] is defined for timetable arrays just like it's defined for many other data types in MATLAB. Let's define two datetime arrays:
>> dt1 = datetime('today')+(-1:1).';
>> dt2 = dt1 + 3;
and two timetable arrays:
>> tt1 = timetable(dt1, [1; 3; 6], [10; 15; 21]);
>> tt2 = timetable(dt2, [1; 4; 9], [16; 25; 36]);
If we combine the two timetable arrays using synchronize, you receive a timetable with six rows and four variables.
>> tt3a = synchronize(tt1, tt2)
tt3a =
6×4 timetable
dt1 Var1_tt1 Var2_tt1 Var1_tt2 Var2_tt2
____________________ ________ ________ ________ ________
16-Sep-2018 00:00:00 1 10 NaN NaN
17-Sep-2018 00:00:00 3 15 NaN NaN
18-Sep-2018 00:00:00 6 21 NaN NaN
19-Sep-2018 00:00:00 NaN NaN 1 16
20-Sep-2018 00:00:00 NaN NaN 4 25
21-Sep-2018 00:00:00 NaN NaN 9 36
If we combine the two timetable arrays using concatenation, we receive a timetable array with six rows but only two variables.
>> tt3b = [tt1; tt2]
tt3b =
6×2 timetable
dt1 Var1 Var2
____________________ ____ ____
16-Sep-2018 00:00:00 1 10
17-Sep-2018 00:00:00 3 15
18-Sep-2018 00:00:00 6 21
19-Sep-2018 00:00:00 1 16
20-Sep-2018 00:00:00 4 25
21-Sep-2018 00:00:00 9 36
Ioannis Tsikriteas
Ioannis Tsikriteas on 22 Sep 2018
Thanks a lot!!! The second method was the answer to my problem!!!

Sign in to comment.

Categories

Find more on Tables 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!