Synchronize / Outerjoin two timetables, without copying shared Variables.
5 ビュー (過去 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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!