Synchronize / Outerjoin two timetables, without copying shared Variables.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nando
am 20 Jun. 2024
Beantwortet: Cris LaPierre
am 20 Jun. 2024
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 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 20 Jun. 2024
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!