Hello Alexander,
However, given that you are using MATLAB R2020a, since direct support for some features might not exist, there are possible solutions and workarounds for both issues:
Adding System Notes to a Report:
Currently, the script-based approach is a good strategy. The method of iterating over systems in a Simulink model and adding notes to the report is valid. However, if “Notes(system)” isn't directly fetching the notes because it's not a built-in function for this purpose, you might need to manually fetch and format the notes from each system. Here's an enhanced approach:
- Fetch System Notes: You'll need to access the notes from each system manually. If the system notes are stored in a block or as a parameter, you'll have to fetch them using “get_param” or similar functions.
- Format and Add Notes: Once you have the notes, format them as text or paragraphs using “mlreportgen.dom” classes and then add them to your section.
Adding Live Scripts to a Report:
For incorporating MATLAB Live Scripts “.MLX files” into your report, converting the live script to a format that's compatible with report (e.g., PDF, DOCX) and then including it is a practical approach. MATLAB doesn't provide direct support for embedding “.MLX” content into reports generated by “slreportgen.report.Report” in R2020a so here's how you can convert and include a live script:
1. Convert Live Script to PDF: First, convert your “.MLX” file to a “.PDF”. While MATLAB R2020a doesn't have a direct function in the Live Editor to export to “DOCX”, you can use “PDF” as an intermediary. Here’s the code snippet:
matlab.internal.liveeditor.openAndConvert('yourScript.mlx', 'yourScript.pdf');
2. Include PDF in Report: Directly embedding a “.PDF” into a “.DOCX” report isn't straightforward. As a workaround, you can include a link in the report that points to the PDF file stored locally or hosted online. Here’s the code snippet:
link = mlreportgen.dom.ExternalLink('path/to/yourScript.pdf', 'See the Live Script here');
Please refer to the following references to know further about:
- Create Report Programs (MathWorks Documentation): https://www.mathworks.com/help/rptgenext/interactive-report-creation.html
- Simulink Report Generator Task Examples: https://www.mathworks.com/help/rptgenext/simulink-report-generator-task-examples.html
- Report Model Notes (MathWorks Documentation): https://www.mathworks.com/help/rptgenext/ug/report_model_notes.html
- MATLAB Report Generator – Custom Report Using Report API (File Exchange): https://www.mathworks.com/matlabcentral/fileexchange/71896-matlab-report-generator-custom-report-using-report-api?s_tid=answers_rc2-2_p5_MLT
Hope this helps!