Concatenate Tables with one variable having different lengths

조회 수: 24 (최근 30일)
JLC
JLC 2019년 6월 16일
댓글: JLC 2019년 6월 16일
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