Concatenate Tables with/without "Join"

1 Ansicht (letzte 30 Tage)
Dario Walter
Dario Walter am 17 Jun. 2019
Kommentiert: Dario Walter am 18 Jun. 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 Kommentare
Matt J
Matt J am 17 Jun. 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 am 17 Jun. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 17 Jun. 2019
Bearbeitet: Matt J am 17 Jun. 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

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by