Main Content

Generate Code Generation Report

You can configure a model to generate a code generation report when you build the model. If you want to separate report generation from code generation, you can manually generate a report after generating code. If you do not change the model after generating code, you can generate a report without regenerating the code.

If you have Embedded Coder®, you can include optional sections in the report, such as reports on traceability and code replacement. For more information, see Reports for Code Generation.

Configure Model

Configure a model to generate code without generating a report.

  1. Open a model, for example, SumModel.

    model = "SumModel";
    openExample(model);
  2. On the C Code tab, from the Open Report list, select Report Options. The Configuration Parameters dialog box opens with the Code Generation > Report pane visible.

  3. Clear the Create code generation report parameter. When you generate code, the report is not generated. Instead, you generate the report manually.

  4. If you have Embedded Coder, verify that Eliminated / virtual blocks (Embedded Coder) is selected. This parameter enables an optional Traceability Report section in the code generation report.

  5. Generate code.

Generate Report

On the C Code tab, select Open Report. The report generation process writes the code generation report files to the html subfolder of the build folder (see HTML Code Generation Report Location) without regenerating the code. Next, a MATLAB® web browser window opens and displays the code generation report.

If you selected Eliminated / virtual blocks, the code generation report includes a Traceability Report section.

To open the code generation report at any time after generating code, on the C Code tab, select Open Report. If a report already exists, it opens without regenerating the code or report.

Share Report

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

  1. In the Current Folder browser, select these folders:

    • /slprj

    • model_target_rtw

  2. To open the context menu, right click one of the selected folders.

  3. In the context menu, select Create Zip File. A file appears in the Current Folder browser.

  4. Name the ZIP file.

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.

Limitations

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 the Open Report button 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, rebuild the model before using the Open Report button.

You cannot open a code generation report that was generated by using a different MATLAB version. If your report was generated in a different version, you can:

  • Open the HTML file for the report outside of MATLAB.

  • Re-generate the report using your MATLAB version.

Related Topics