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 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.


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.


Build the 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 14.158s

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'.,GenerateTraceReport='on');

The code generation report includes a Traceability Report section.

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

ans = 

Close the code generation report.;

To reopen the report programmatically, use;

Share Report

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


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.


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 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, rebuild the model.

See Also

| |

Related Topics