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 coder.report.generate, coder.report.open, and coder.report.close 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";
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: 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 coder.report.open command.

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

The code generation report includes a Traceability Report section.

Verify that GenerateTraceReport is off 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("SumModel",["slprj","SumModel_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