Main Content

Generate MATLAB Code from Report Setup File

You can generate MATLAB® code versions of report setup files in the form of a MATLAB file (*.m). A MATLAB file of a report setup file is useful for various purposes, including generating reports and modifying report setup files programmatically.

To update a MATLAB file, load a report setup file into the Report Explorer and click File > Generate MATLAB File. After the MATLAB file generates, it opens in the MATLAB Editor. The filename for the generated file is the file name of the report setup file , preceded by “build.”

Example 1. Generate Reports from MATLAB Files

This example generates a MATLAB file from the figloop_tutorial.rpt report setup file, which is part of the MATLAB Report Generator™ software. The example then uses the report function to generate a report from the MATLAB file. For more information about this function, see the report reference page.

  1. Start the Report Explorer by entering report in the MATLAB Command Window.

  2. In the Options pane in the middle, double-click figloop_tutorial.rpt to open its report setup file.

  3. In the Outline pane on the left, click Report - figloop_tutorial.rpt to select it.

  4. In the Report Explorer menu bar, click File > Generate MATLAB File.

    The MATLAB Report Generator software generates MATLAB code for the figloop_tutorial.rpt report setup file. It saves this code in the buildfigloop_tutorial.m file in the folder you specify. Part of this file appears in the following figure.

    Editor window displaying buildfigloop_tutorial.m

  5. To generate the figloop_tutorial report from this MATLAB file, run the following command in the MATLAB Command Window:

     report(buildfigloop_tutorial);
    The MATLAB Report Generator software runs and displays the report.

    The Figure Loop report sample showing title, subtitle, author, date, abstract, and chapter