How to combine tables and add new row

5 visualizaciones (últimos 30 días)
YouBetterWerk
YouBetterWerk el 3 de Abr. de 2018
Respondida: Akira Agata el 5 de Abr. de 2018
AA =
Scene Time simA1A2 simA1 simA2 sadA1A2 sadA1 sadA2
_______ ____ _______ ______ _______ _______ _______ ________
Default 30 0.77551 0.2551 0.52041 0.18367 0.14286 0.040816
BB =
Scene Time simA1A2 simA1 simA2 sadA1A2 sadA1 sadA2
___________ ____ _______ _______ _______ _______ ________ _______
[1x42 char] 8 0.69388 0.21429 0.47959 0.14286 0.020408 0.12245
CC =
Scene Time simA1A2 simA1 simA2 sadA1A2 sadA1 sadA2
___________ ____ _______ _______ _______ _______ _______ ________
[1x44 char] 3 0.63265 0.18367 0.44898 0.26531 0.22449 0.040816
DD =
Scene Time simA1A2 simA1 simA2 sadA1A2 sadA1 sadA2
___________ ____ _______ _______ _______ _______ _______ ________
[1x43 char] 3 0.63265 0.18367 0.44898 0.14286 0.10204 0.040816
I have 4 tables that I wish to combine into a single table with the same header. Is it possible? I tried the join function but I keep getting error messages.
  3 comentarios
YouBetterWerk
YouBetterWerk el 3 de Abr. de 2018
I tried this, but it didnt work because the character length under "scene" is not the same.
Instead, I combined all the data into a structure and converted the structure to a table.
Guillaume
Guillaume el 3 de Abr. de 2018
For future reference, the reason why Akira's answer does not work is because of the way you create the tables in the first place. It's a bit unusual to have tables with only one row, but if you intend to have a table with several rows of char arrays of different length, then you must wrap any char array into a cell array:
AA = table({'Default'}, 30, ...
instead of
AA = table('Default', 30, ...

Iniciar sesión para comentar.

Respuestas (1)

Akira Agata
Akira Agata el 5 de Abr. de 2018
OK, I understand the situation. How about the following script?
Scene = {AA.Scene; BB.Scene; CC.Scene; DD.Scene];
T = [table(Scene), [AA(:,2:end); BB(:,2:end); CC(:,2:end); DD(:,2:end)]];

Categorías

Más información sobre Tables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by