Concatenate Tables with/without "Join"

1 visualizzazione (ultimi 30 giorni)
Dario Walter
Dario Walter il 17 Giu 2019
Commentato: Dario Walter il 18 Giu 2019
Hey guys,
I could really need your help right now!
Let us assume
A = table(['A';'B';'C';'D';'E'],[38;43;38;40;49],...
'VariableNames',{'Character' 'Time1'})
B = table(['A';'C';'D';'E';'F'],[92;46;29;50;57],...
'VariableNames',{'Character' 'Time2'})
I want to create table in such a way that it returns
C=table(['A';'B';'C';'D';'E';'F'],[38;43,38;40;49;nan],[92;nan;46;29;50;57])
Do you have any idea? Thanks for your help!
  2 Commenti
Matt J
Matt J il 17 Giu 2019
Your code to generate C generates an error
>> C=table(['A';'B';'C';'D';'E';'F'],[38;43,38;40;49;nan],[92;nan;46;29;50;57])
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
And what do you mean by "with/without Join"? Do you mean either is acceptable?
Dario Walter
Dario Walter il 17 Giu 2019
Please apologize, there was a comma instead of a semicolon.
C=table(['A';'B';'C';'D';'E';'F'],[38;43;38;40;49;nan],[92;nan;46;29;50;57])
Exactly, I do not mind how it works. It just has work.

Accedi per commentare.

Risposta accettata

Matt J
Matt J il 17 Giu 2019
Modificato: Matt J il 17 Giu 2019
>> C = outerjoin(A,B,'Keys','Character','MergeKeys',true)
C =
6×3 table
Character Time1 Time2
_________ _____ _____
A 38 92
B 43 NaN
C 38 46
D 40 29
E 49 50
F NaN 57

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by