How to Join Tables in report generator?

조회 수: 10 (최근 30일)
John
John 2020년 10월 13일
댓글: Rahul Singhal 2020년 10월 14일
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!

채택된 답변

Rahul Singhal
Rahul Singhal 2020년 10월 13일
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
John
John 2020년 10월 13일
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 2020년 10월 14일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by