Documentation

Model Loop

Loop on Simulink models and systems, as specified by child components

Description

This component loops on Simulink® models and systems, as specified by child components. For example, you can use a Model Loop with a child System Loop to report on the subsystems of the specified system.

Consider making these components children of the Model Loop (although the Model Loop is not necessarily required to be the immediate parent of a given component).

For conditional processing based of blocks, you can use the RptgenSL.getReportedBlock function. For more information, see Loop Context Functions.

Models to Include

You can add a model to the list by clicking Add New Model to List. The following table shows the buttons you can use to move a model up or down in the list, or to add or delete a model.

Button

Action

Move a model up in the list.

Move a model down in the list.

Remove a model from the list.

Add a new model to the list.

Model Options

  • Active: Includes a given model in the loop. This option is selected by default. Clearing this option omits the model from the loop.

    This option allows you to temporarily omit one or more models from a report.

  • Model name: Specifies the model name.

    • Current block diagram

    • All open models

    • All open libraries

    • Block diagrams in current directory

    • Custom block diagram: Selecting this option automatically sets the Starting system(s) field $top to start in the model root system.

    • %<VariableName>: For more information, see %<VariableName> Notation on the Text component reference page in the MATLAB® Report Generator™ documentation.

  • Traverse model: Specifies the systems to traverse.

    • All systems in model

    • Selected system(s) only

    • Selected system(s) and ancestors

    • Selected system(s) and children

  • Look under masks: Specifies how to handle masks.

    • Functional masks only

    • No masks

    • All masks

    • Graphical masks only

    For more information, see Block Masks (Simulink).

  • Follow library links: Specifies library links to include.

    • Do not follow library links: Library links are treated as blocks.

    • Include library links: Library links are treated as subsystems.

    • Include unique library links: With multiple copies of the same library link in a system, one is treated as a subsystem and the others as blocks.

    For more information, see Linked Blocks (Simulink).

  • Model reference: Specifies whether to report on models referenced by a Model block. If you want to report on referenced models, then you can control the depth of the model referencing hierarchy and whether to report on model reference variants.

    • Do not follow model reference blocks: Do not report on blocks contained in referenced models.

    • Follow all model reference blocks: Report on blocks contained in all models that any part of the model hierarchy references.

    • Follow model reference blocks defined in current model: Report on blocks in models that the currently selected model references.

    • <Custom model reference depth>: Report on blocks in models that your specified level in the model reference hierarchy references.

  • Include all variants: Report on all model reference variants. To enable this option, set the Model reference option to report on blocks in referenced models.

  • Starting system(s): Specifies the system in which to start the loop. Available options depend on the value that you select in the Traverse model option. Selecting any option other than All systems in model for Traverse model activates the Starting system(s) option.

    If you do not enter a model name in the Model name option, then select either Root model or Current to specify where to start the loop.

    If you specify a model name in the Model name option, then the Starting system(s) option provides an edit box in which you can enter:

    • The full path of a subsystem or subsystems

    • $top to start the loop in the model root system

    • $current to start the loop in the currently selected system

Section Options

  • Create section for each object in loop: Inserts a section in the generated report for each object found in the loop.

  • Display the object type in the section title: Inserts the object type automatically into the section title in the generated report.

  • Create link anchor for each object in loop: Create a link target for each model in the loop so that other parts of the report can link to it.

Examples

Example 1. Generating Reports on Specified Systems and their Subsystems

This example shows how to loop over a specified system and its subsystems in the sample model sldemo_auto_climate_elec, which the Simulink software includes.

  1. (Optional) To open the sldemo_auto_climate_elec model, at the MATLAB command prompt, enter the following command:

    sldemo_auto_climate_elec

    Explore the model to familiarize yourself with its subsystems.

  2. Open the Report Explorer.

  3. Create a report setup file by clicking File > New.

  4. Save the report setup file by clicking File > Save As. Give it the name sldemo_auto_report.

  5. Add a Chapter/Subsection component to the report setup file to include information about model subsystems:

    1. In the Library pane in the middle, double-click Chapter/Subsection to add it to the report setup file.

    2. For Title, choose Custom. In the title field, enter Description of subsystems.

    3. Add a Model Loop as a child of the Chapter/Subsection component. This loops over the ClimateControlSystem system and its subsystems in the sldemo_auto_climate_elec model:

      1. In the Library pane in the middle, double-click Model Loop to add it to the report setup file. By default, the Report Explorer adds that component as a child of the Chapter/Subsection component.

      2. In the Model Loop properties pane, from the Model name selection list, select <Custom block diagram> .

      3. In the Model name field, delete the text <Custom block diagram>, and then enter sldemo_auto_climate_elec.slx. Click any component in the report setup file to add this model to the Models to include list.

      4. In the Traverse model selection list, select Selected system(s) and children.

      5. In the Look under masks selection list, select All masks.

      6. In the Model reference selection list, select Do not follow model reference blocks.

      7. In the Starting system(s) field, enter sldemo_auto_climate_elec/ClimateControlSystem. Because you selected Selected system(s) and children for Traverse model, the Model Loop loops over sldemo_auto_climate_elec/ClimateControlSystem and its subsystems.

      8. Under Section Options, select the Create section for each object in loop check box. Selecting this option creates separate sections in the generated report for each model over which the component loops.

      The Model Loop properties pane looks as follows.

  6. Save the report by clicking File > Save.

  7. Add a System Loop as a child of the Model Loop component.

    1. In the Library pane in the middle, double-click System Loop to add it to the report setup file. By default, Model Explorer adds this component as a child of the Model Loop component.

    2. In the System Loop properties pane, under Loop Options, select the Create section for each object in loop check box. Selecting this option creates a section in the generated report for each subsystem on which the component loops. Accept the default values for all other fields.

  8. Add a System Snapshot component as a child of the System Loop component. This step creates snapshots of all the subsystems of ClimateControlSystem in the generated report. In the Library pane in the middle, double-click System Snapshot. By default, Model Explorer adds this component as a child of the System Loop component.

  9. Save the report.

    The report setup file hierarchy now looks as follows.

  10. Run the report by clicking File > Report.

    The report loops on the system ClimateControlSystem of the sldemo_auto_climate_elec model and all of its subsystems, as shown in the following Message List.

Below is an excerpt from the generated report.

Example 2. Temporarily Omitting a Model from a Loop

This example shows how to use the Model Loop Active check box to temporarily omit a model from the loop. This example uses the report setup file that you created in the Generating Reports on Specified Systems and their Subsystems example above, sldemo_auto_report.rpt, and the f14 model, which is included with Simulink

  1. In the Report Explorer, click File > Open, and then open sldemo_auto_report.rpt by double-clicking it.

  2. In the Outline pane on the left, click Model Loop Section 1 - sldemo_auto_climate_elec.

  3. In the Model Loop properties pane, click the button to add a model to the Models to include list.

  4. In the Model Loop properties pane, from the Model name selection list, select <Custom block diagram>.

  5. In the Model name field, delete the text <Custom block diagram> and enter f14.mdl.

    The Model Loop properties pane now looks as follows.

  6. Save the report setup file.

  7. Generate the report.

    The report generation process loops over the specified systems in the f14 and sldemo_auto_climate_elec models, as shown in the following message box.

    Below is an excerpt from the generated report.

  8. In the Models to include list, click f14 to select it.

  9. Clear the Active check box to omit f14 model information from the generated report.

  10. Rerun the report.

    The report now includes information only on the sldemo_auto_climate_elec model, as shown at the end of the previous example, Generating Reports on Specified Systems and their Subsystems.

  11. To reactivate the f14 model, in the Model Loop Models to include list, select the f14 model and then select the Active check box.

Insert Anything into Report?

Yes, inserts a section if you select Create section for each object in loop and a link target if you select Create link anchor for each object in loop.

Class

rptgen_sl.csl_mdl_loop

Was this topic helpful?