Error Concatenating multiple tables

I need to concatenate multiple tables vertically. All tables have the same Variable Names in the columns and they have the same number of columns.
Respectively:
S1 -> 93x27 table
T1 ->126x27 table
S2 ->192x27 table
T2 ->252x27 table
I am using this approach:
Complete_Data = [S1; T1; S2; T2]
I get this error:
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Can you please help?
Thank you in advance :)

 Respuesta aceptada

Jakeb Chouinard
Jakeb Chouinard el 3 de Ag. de 2021
Since I can't see what exactly is within these tables, I'll take a shot in the dark:
This could be due to the data-types within the tables. If you're trying to vertically concatenate character array table entries, for instance, if the two tables do not have the same length for these arrays, it would have the same effect as attempting the below:
['abc';'de']
If their concatenation is necessary, it may be necessary to convert these char arrays to strings or cells of char arrays. For some information regarding this, I'll direct you here.
If this is not the case, could you please supply us with more information regarding what is in the tables? E.g. run the below:
whos
or
summary(table)

4 comentarios

Nina Perf
Nina Perf el 3 de Ag. de 2021
Editada: Nina Perf el 3 de Ag. de 2021
Thank you so much. One column variable (tfi) has 1x1 struct in all rows. This variable is in all Tables I want to concatenate.
Some column variables summary are as follows:
ts: 93×2 char
tt: 93×1 double
tsu: 93×1 cell array of character vectors
tfi: 93×1 cell
Do you know how I can solve this?
Jakeb Chouinard
Jakeb Chouinard el 3 de Ag. de 2021
Since its important to understand where exactly the problem is occuring, would it be possible for you to attempt to concatenate each column individually (my suggestion would be to put a debug break before the programmed concatenation and attempt to concatenate one column at a time via the Command Terminal Window)? This could help us identify where exactly the problem is.
For every table, are the dimensions of ts the same? Are the structs in all tables the same? As Stephen pointed out, different datatype sizes in structs could cause issues in vertical concatenation. A 1x1 struct is more than just a 1x1 struct, as it could contain several types and sizes of data.
Nina Perf
Nina Perf el 3 de Ag. de 2021
Thank you I solved it :)
Jakeb Chouinard
Jakeb Chouinard el 3 de Ag. de 2021
Nice job! Cheers, Jakeb

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Preguntada:

el 3 de Ag. de 2021

Comentada:

el 3 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by