How to include DOC contents in the report generated by Simulink Automatically
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
We have software written in Simulink model and would like to add some information in DOC blocks along with other Simulink blocks in different layers. Is there a way to generate the Reports showing the contents of DOC blocks automatally. I can generate the report but it will not show the contents of DOC in it. Thank you.
0 comentarios
Respuestas (1)
Akanksha
el 22 de Jun. de 2025
The contents of Simulink DocBlock blocks can be included in automatically generated reports using the Simulink Report Generator along with the MATLAB Report API. Here's how to achieve it:
Use the Report API – The slreportgen.report.DocBlock class is designed to pull content from DocBlocks and include it in your report.
Find the DocBlocks – Use slreportgen.finder.BlockFinder and set the MaskType to 'DocBlock' to locate them in your model.
Add Them to the Report – Loop through the found blocks and use the add method to include them in your report.
Here's a simplified version of the code from the official MathWorks example :
import mlreportgen.report.*
import slreportgen.report.*
import slreportgen.finder.*
model = 'your_model_name';
load_system(model);
rpt = slreportgen.report.Report('MyReport','docx');
rpt.CompileModelBeforeReporting = false;
add(rpt, TitlePage('Title', 'Model Documentation'));
add(rpt, TableOfContents);
finder = SystemDiagramFinder(model);
for system = find(finder)
ch = Chapter('Title', sprintf('System %s', system.Name));
docBlockFinder = BlockFinder(system);
docBlockFinder.Properties = {'MaskType', 'DocBlock'};
results = find(docBlockFinder);
if ~isempty(results)
add(ch, results);
else
add(ch, "This system does not have documentation.");
end
add(rpt, ch);
end
close(rpt);
close_system(model);
rptview(rpt);
PFA the official MathWorks documentation for further information:
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Simulink Report Generator 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!