Skip to Main Content Skip to Search
Product Documentation

Document a Code Generation Project Using the Simulink Report Generator

The Simulink Report Generator software creates documentation from your model in multiple formats, including HTML, PDF, RTF, Microsoft Word, and XML. This example shows one way to document a code generation project in Microsoft Word. The generated report includes:

To adjust Simulink Report Generator settings to include custom code and then generate a report for a model, complete the following tasks:

  1. Generate Code for the Model

  2. Open the Report Generator

  3. Set Report Name, Location, and Format

  4. Specify Models and Subsystems to Include in a Report

  5. Customize the Report

  6. Generate the Report

For more information on generating other reports, see the Simulink Report Generator User Guide.

Generate Code for the Model

Before you use the Report Generator to document your project, you must generate code for the model.

  1. In the MATLAB Current Folder browser, navigate to a folder where you have write access.

  2. Create a working folder from the MATLAB command line by typing:

    mkdir report_ex
  3. Make report_ex your working folder:

    cd report_ex
  4. Open the rtwdemo_f14 model by clicking the following model name below or by entering the model name on the MATLAB command line:

    rtwdemo_f14
  5. In the model window, choose File > Save As, navigate to the working folder, report_ex, and save a copy of the rtwdemo_f14 model as myf14.mdl.

  6. Open Model Explorer by selecting Model Explorer from the model View menu.

  7. In the Model Hierarchy pane, click the + sign preceding the model name to reveal its components.

  8. In the left pane, click Configuration (Active).

  9. In the center pane, click Code Generation.

  10. In the Code Generation pane, select the Report tab. Clear the Create code generation report and Open report automatically check boxes.

  11. Select the General tab. Select Generate code only, and click Apply.

  12. Click Generate code. The Simulink Coder build process generates code for the model.

Open the Report Generator

After you generate the code, open the Report Generator.

  1. In the model window, select Tools > Report Generator.

  2. In the Report Explorer window, in the options pane (center), find the folder rtw (\toolbox\rtw) and the setup file that it contains, codegen.rpt.

  3. Double-click codegen.rpt or select it and click the Open report button . The Report Explorer displays the structure of the setup file in the outline pane (left).

Set Report Name, Location, and Format

Before generating a report, you can specify report output options, such as the folder, file name, and format. For example, to generate a Microsoft Word report named MyCGModelReport.rtf:

  1. In the properties pane, under Report Options, review the options listed.

  2. Leave the Directory field set to Present working directory.

  3. For Filename, select Custom: and replace index with the name MyModelCGReport.

  4. For File format, specify Rich Text Format and replace Standard Print with Numbered Chapters & Sections.

Specify Models and Subsystems to Include in a Report

Specify the models and subsystems that you want to include in the generated report by setting options in the Model Loop component.

  1. In the outline pane (left), select Model Loop. Report Generator displays Model Loop component options in the properties pane.

  2. If not already selected, select Current block diagram for the Model name option.

  3. In the outline pane, click Report - codegen.rpt*.

Customize the Report

After specifying the models and subsystems to include in the report, you can customize the sections included in the report.

  1. In the outline pane (left), expand the node Chapter - Generated Code. By default, the report includes two sections, each containing one of two report components.

  2. Expand the node Section 1 — Code Generation Summary. The Code Generation Summary component displays.

  3. Select Code Generation Summary. Options for the component are displayed in the properties pane.

  4. Click Help to review the report customizations that you can make with the Code Generation Summary component. For this example, do not customize the component.

  5. Return focus to the Report Explorer window and expand the node Section 1 — Generated Code Listing. The Import Generated Code component displays.

  6. Select Import Generated Code. Options for the component are displayed in the properties pane.

  7. Click Help to review the report customizations that you can make with the Import Generated Code component.

  8. Return focus to the Report Explorer window.

Generate the Report

After you adjust the report options, from the Report Explorer window, generate the report by clicking File > Report. A Message List dialog box opens, which displays messages that you can monitor as the report is generated. Model snapshots also appear during report generation. The Message List dialog box might be hidden behind other dialog boxes.

For alternative ways of generating reports, see Generate a Report in the Simulink Report Generator documentation.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS