Can you synchronize two or more timetables if each timetable has a different number of rows and columns?
16 次查看(过去 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!