Synchronize / Outerjoin two timetables, without copying shared Variables.
3 次查看(过去 30 天)
显示 更早的评论
I have two timetables. They have some variable names in common, and some they don't.
They have no times in common.
Tt1 = (times1,'A','B','C');
Tt2 = (times2,'B','D');
T_join = [Tt1;Tt2]; %Doesn't work because some variables aren't the same
T_join = synchronize(Tt1,Tt2); % Gives me two 'B'-Colums ('B_1' and 'B_2')
I would like T_join to have the Variables ['A', 'B', 'C', 'D'] where 'B' is basically [B_1 ; B_2]
(Like outerjoin MergeKeys, I would like to merge colums, which outerjoin can't do with timetables).
Is there a function that can do this? Maye with a specific "Name,Value" combination?
0 个评论
采纳的回答
Cris LaPierre
2024-6-20
outerjoin works with timetables. However, what you have shared here is not a timetable. Define your left and right keys to be times and the shared variable, then set the MergeKeys name-value pair to true to combine variables.
A = rand(10,1);
B = rand(10,1);
C = rand(10,1);
D = rand(10,1);
times1 = (datetime(2024,5,1):minutes(1):datetime(2024,5,1)+minutes(9))';
times2 = (datetime(2024,5,1):minutes(2):datetime(2024,5,1)+minutes(18))';
Tt1 = timetable(times1,A,B,C);
Tt2 = timetable(times2,B,D);
T_join = outerjoin(Tt1,Tt2,"LeftKeys",["times1","B"],"RightKeys", ["times2","B"],'MergeKeys',true)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Timetables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!