Concatenate Tables with one variable having different lengths

32 Ansichten (letzte 30 Tage)
JLC
JLC am 16 Jun. 2019
Kommentiert: JLC am 16 Jun. 2019
I am trying to concatentate two tables within which the first variable is a string of different lengths, between tables.
T1 = table('Alpha', 33, 6); % Create first table
T2 = table('DoubleAlpha', 36, 8); % Create second table
TT = vertcat(T1,T2); % Concatenate tables
This gives an error:
Could not concatenate the table variable 'Var1' using VERTCAT.
Caused by:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Is there an additional argument or way to initialize an empty table to permit vertcat?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 16 Jun. 2019
Bearbeitet: Walter Roberson am 16 Jun. 2019
Later versions than yours reject your input syntax because of ambiguity about options versus inputs.
T1 = table({'Alpha'}, 33, 6); % Create first table
T2 = table({'DoubleAlpha'}, 36, 8); % Create second table
TT = vertcat(T1,T2); % Concatenate tables
The error message for your syntax in modern versions is
You might have intended to create a one-row table with the character vector 'Alpha' as one of its variables. To store text data in a table, use a string array or a cell array of character vectors rather than character arrays. Alternatively, create a cell array with one row, and convert that to a table using CELL2TABLE.

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by