How to Join Tables in report generator?

2 visualizaciones (últimos 30 días)
John
John el 13 de Oct. de 2020
Comentada: Rahul Singhal el 14 de Oct. de 2020
If the code goes like this:
import mlreportgen.dom.*
tablecontent1 = { ... };
table1 = Table(tablecontent1);
...
tablecontent2 = { ... };
table2 = Table(tablecontent2);
...
Assuming 2 tables have same colomn number and definitively can adjust some other properties.
How can join them into one single table?
Thanks!

Respuesta aceptada

Rahul Singhal
Rahul Singhal el 13 de Oct. de 2020
Hi John,
You can combine the cell array content and then create the DOM Table:
import mlreportgen.dom.*
tablecontent1 = { ... };
...
tablecontent2 = { ... };
...
% Combine the table content cell arrays and then create DOM Table
tableContent = [tablecontent1; tablecontent2];
table = Table(tableContent);
...
Thanks,
Rahul
  2 comentarios
John
John el 13 de Oct. de 2020
Hi, Rahul:
That was the issue. Because the Tables were made in different places and with lots of operations.If combining the cell array, it will requires complete recoding for all. That's why we seek whether if the 2 Tables can be joined together as DOM Tables.
Thanks.
John
Rahul Singhal
Rahul Singhal el 14 de Oct. de 2020
Hi John,
In this case, you can merge the DOM tables as shown below:
import mlreportgen.dom.*
tablecontent1 = { ... };
table1 = Table(tablecontent1);
...
tablecontent2 = { ... };
table2 = Table(tablecontent2);
...
% First create a copy of the first table.
% This will make sure that the new "mergedTable" has all the content of table1.
mergedTable = clone(table1);
% Now add second table content to the "mergedTable".
% This is done by adding a copy of each row of second table to the "mergedTable".
for i=1:length(table2.Children)
row = table2.Children(i);
append(mergedTable,clone(row));
end
Thanks,
Rahul

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by