Concatenate Tables with one variable having different lengths

32 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2019-6-16
编辑:Walter Roberson 2019-6-16
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by