Concatenate Tables with one variable having different lengths

19 vues (au cours des 30 derniers jours)
JLC
JLC le 16 Juin 2019
Commenté : JLC le 16 Juin 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?

Réponse acceptée

Walter Roberson
Walter Roberson le 16 Juin 2019
Modifié(e) : Walter Roberson le 16 Juin 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.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by