How to Join Tables in report generator?

6 vues (au cours des 30 derniers jours)
John
John le 13 Oct 2020
Commenté : Rahul Singhal le 14 Oct 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!

Réponse acceptée

Rahul Singhal
Rahul Singhal le 13 Oct 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 commentaires
John
John le 13 Oct 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 le 14 Oct 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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Report Generator dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by