Main Content

Configure and Generate Code Generation Report Programmatically

You can programmatically generate, open, and close an HTML code generation report at the MATLAB® command line using the,, and functions respectively. 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 = "SumModel";

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: SumModel
### Successful completion of build procedure for: SumModel

Build Summary

Top model targets built:

Model     Action                        Rebuild Reason                                    
SumModel  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 11.861s

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'. Then open the report with the command.,GenerateTraceReport='on');;

The code generation report includes a Traceability Report section.

Verify that GenerateTraceReport is off 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