Combine Timetable's
조회 수: 24 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Peter Perkins
2018년 9월 12일
Perhaps
tt12 = [tt1; tt2]
i.e., just like any other MATLAB array.
댓글 수: 3
Steven Lord
2018년 9월 17일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!