Main Content

Generate Code Generation Report Programmatically

You can programmatically generate, open, and close an HTML code generation report at the MATLAB command line using the coder.report.generate function. When you generate the report, you can configure it rather than tie the report configuration to the model configuration set. If you do not change the model after generating code, you can generate a code generation report without regenerating the code.

Configure Model

Open the model.

model='rtwdemo_sum';
open_system(model)

Clear the GenerateReport configuration parameter programmatically. When you build the code, the report is not generated. Instead, you generate the report manually at the command line.

set_param(model,'GenerateReport','off');

Build the model.

slbuild(model);
### Starting build procedure for: rtwdemo_sum
### Successful completion of build procedure for: rtwdemo_sum

Build Summary

Top model targets built:

Model        Action                       Rebuild Reason                                    
============================================================================================
rtwdemo_sum  Code generated and compiled  Code generation information file does not exist.  

1 of 1 models built (0 models already up to date)
Build duration: 0h 0m 8.5564s

Generate Report

When you generate the report at the command line, you can use name-value arguments to configure the report without changing the model configuration set. Generate the report with GenerateTraceReport set to 'on'.

coder.report.generate(model,GenerateTraceReport='on');

The code generation report includes a Traceability Report section.

Verify that GenerateTraceReport is not selected in the model configuration set.

get_param(model,'GenerateTraceReport')
ans = 
'off'

Close the code generation report.

coder.report.close();

To reopen the report programmatically, use coder.report.open.

coder.report.open(model);

Share Report

To share the code generation report, package the code generation report files and supporting files into a ZIP file for transfer.

zip('myzip',{'slprj','rtwdemo_sum_ert_rtw'});

If your model is part of a project, you can include the code generation report when archiving the project. For more information, see Archive Projects.

Limitation

After building your model or generating the code generation report, if you modify legacy or custom code, you must rebuild your model or regenerate the report for the code generation report to include the updated legacy source files. For example, if you modify your legacy code, and then use coder.report.open to open an existing report, the software does not check if the legacy source file is out of date compared to the generated code. The code generation report is not regenerated and the report includes the out-of-date legacy code.

To reflect changes to legacy or custom code in the code generation report, before using coder.report.open, rebuild the model.

See Also

| |

Related Topics