Can you synchronize two or more timetables if each timetable has a different number of rows and columns?
조회 수: 14 (최근 30일)
이전 댓글 표시
I have 8 csv files with different types of sensor data. 5 of the files have 3 columns (variables) and 3 of the files have 14 columns. The one column that all the files share is UTC Time. Each file has a different number of rows. Is it possible to use timetables and synchronize to create a single table sorted by time that would then be written to a new csv file? What other MATLAB commands/features might be helpful here? Thank you-
댓글 수: 1
dpb
2023년 10월 3일
The description of synchronize says it "collects the variables from all input timetables, synchronizes them to a common time vector, and returns the result as a single timetable. ... In effect, synchronize horizontally concatenates the variables of [the input timetables] even when they have row times that differ. As a result, synchronize inserts a missing data indicator in [the output timetable wherever there are missing data from one table at an input time]. If [input timetables] have variables with the same names, then synchronize renames them and copies [all] variables into [the output timetable]."
If that's what you want to happen, then "yes".
Otherwise, you may want to look at the various join functions.
채택된 답변
SAI SRUJAN
2023년 10월 9일
Hi Nina Sweeney,
I can understand that you want to synchronize two or more timetables using MATLAB commands/features.
You can follow the below given example.
Suppose there are two timetables that have different rows and columns. "timetable1" consists of 3 rows and 1 column, while "timetable2" has dimensions of 4 rows and 2 columns. If we combine the two timetable arrays using "synchronize",the resulting timetable will encompass six rows and three variables.
dt1 = datetime('today')+(-1:1).'; % 3x1 datetime array
dt2 = datetime('today')+(-1:2).'+ 2; % 4x1 datetime array
timetable1=timetable(dt1,[1;2;3]); % 3x1 timetable
timetable2=timetable(dt2,[4;5;6;7],[8;9;10;11]); % 4x2 timetable
TT1=synchronize(timetable1,timetable2) % 6x3 timetable
You can refer to the similar community questions for your reference.
You can refer to the below documentation to understand more about "synchronize" function in MATLAB.
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!