Main Content

Create Simulink Report Generator Reports Interactively

This example shows how to use the Report Explorer to design a report setup file and generate a report that does the following:

  • Opens a Simulink® model for the van der Pol equation, called the slrgex_vdp model.

  • Sets the Gain parameter for the Mu block to five different values.

  • Simulates the model each time the Gain parameter is set.

  • Collects the results. Results that fall within a specified range appear in a table in the generated report.

You do not need to know MATLAB® or Simulink software to create and run this example report. However, knowledge of these products will help you understand the MATLAB code and model simulation that executes.

Run the following command to access the supporting files used in this example.

openExample('rptgenext/SimulinkReportGeneratorFilesExample');

To create this report, you perform these main tasks:

This example includes separate sections for different kinds of report creation and generation task. Each section builds on the previous sections. However, if you want to see the report setup components for a later section without doing the previous sections, in MATLAB you can view the completed report setup file by opening the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt

The report is for the slrgex_vdp model.

Specify Report Options in Setup Files

To create and configure the report setup file:

  1. Start Simulink.

  2. Open the Report Explorer from the Simulink Toolstrip. On the Apps tab, in the Simulation Graphics and Reporting section, click Report Generator.

  3. Select File > New to create a report setup file.

  4. Save the report setup file.

    In the Properties pane:

    1. Specify where to save the report setup file. To save it in the current working folder, select Present Working Directory from the Directory selection list.

    2. Specify the report format. In the File format selection list, select Acrobat (PDF).

      Tip

      In your reports, if you want to include hyperlinks in system snapshots, use Direct PDF (from template) file format.

    3. Enter a description for the report. In the Report description text box, replace the existing contents with the following text.

      Tip

      Copy and paste this code from the HTML documentation into the Report Explorer.

      Simulink Dynamic Report
      
      This report opens up a model, sets a block parameter 
      several times, simulates the model, and collects the
      results. Results that fall within a specified range are 
      displayed in a table after the test is complete.
      
      The report is configured to test the slrgex_vdp model only.
      By selecting the Eval String component immediately 
      below the Report component, you can modify
      * model
      * block
      * parameter
      * tested values
  5. Click File > Save As to save the report setup file as simulink_tutorial.rpt.

    The Outline pane on the left displays the new file name.

To create the content for the report, see Add Report Content with Components.

Add Report Content with Components

Report Components

Report components specify what information to include in the report. Components are self-contained, modular MATLAB objects that control the report-generation process and insert elements, such as tables, lists, and figures, into a report setup file. Use components to customize the appearance and output of reports.

For more information, see Report Components.

The following figure shows a sample page from the report you create in this example, and which components you use to produce this output.

Note

Do not deactivate report components that you add to the report setup file.

Add MATLAB Code

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

The first component to add is the Evaluate MATLAB Expression component, which evaluates MATLAB commands in the workspace. The code in this component assigns initial values to variables used in this example.

  1. In the Outline pane on the left, select simulink_tutorial.rpt.

  2. In the Library pane in the middle, under the MATLAB category, select Evaluate MATLAB Expression.

  3. In the Properties pane on the right, click the icon next to Add component to current report to insert the component into the report.

    Note

    You cannot edit the component information in the Properties pane on the right until you add the component to the report.

    In the Outline pane on the left, the Evaluate MATLAB Expression component appears under the simulink_tutorial report setup file. The Simulink Report Generator™ software abbreviates the component name to Eval.

    The icon in the upper left corner of the Eval component icon indicates that this component cannot have child components. By default, any components you add while the Eval component is selected are siblings of this component.

    The options for the Evaluate MATLAB Expression component appear in the Properties pane on the right.

  4. Clear the Insert MATLAB expression in report and the Display command window output in report check boxes so you do not include MATLAB code or output in this report.

  5. Add MATLAB code to the Expression to evaluate in the base workspace text box to specify the following values:

    • The model name

    • The block name

    • The block parameter

    • Parameter values

    • Other initial values required for processing the slrgex_vdp model

    Replace the existing text with the following MATLAB code.

    %The name of the model
    %which will be changed
    expModel='slrgex_vdp';
    
    %The name of the block in the model
    %which will be changed
    expBlock='slrgex_vdp/Mu';
    
    %The name of the block parameter
    %which will be changed
    expParam='Gain';
    
    %The values which will be set
    %during experimentation.
    expValue=[-1 0 .5 1 2];
    
    %expValue can be either a vector
    %or a cell array
    
    testMin=2.1;
    testMax=3;
    
    %---- do not change code below line ---
    
    try
       open_system(expModel);
    end
    
    expOkValues=cell(0,2);

    Note

    When you change a field in the Properties pane on the right, the field background changes color (the default is a cream color), indicating that there are unapplied changes to that field. As soon as you perform operations on another component, the Simulink Report Generator software applies the changes, and the background color becomes white again.

  6. Select the Evaluate this expression if there is an error check box.

  7. In the field under the check box, replace the existing text with the following text:

    disp(['Error during eval: ', evalException.message])
    The Report Explorer window now looks as follows.

    Tip

    To run the commands that you specified in your MATLAB expression, click the Eval Now button. This button is located at the upper-right corner of the Report Explorer. This is an easy way to ensure that your commands are correct and will not cause report generation problems.

  8. Click File > Save to save the report setup file.

For information about handling error conditions, see Error Handling for MATLAB Code.

Add a Title Page

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

Create a custom title page for your report using the Title Page component.

  1. In the Outline pane on the left, select the Eval component.

  2. In the Library pane in the middle, under the Formatting category, click Title Page.

  3. Click the icon next to Add component to current report.

    The Title Page component appears in the Outline pane.

    Note

    To use the Title Page component, you need to have a Chapter component in your report. You have not yet added a Chapter component, so the Properties pane displays a message indicating that chapters are required for the Title Page component to appear correctly. Because later in this example you add Chapter components to this report, you can ignore that message.

  4. In the Properties pane on the right:

    1. In the Title text box, enter:

      Dynamic Simulink Report
    2. In the Subtitle text box, enter:

      Using Simulink Report Generator to Document Changes
    3. In the Options section, choose Custom Author from the selection list.

    4. Enter your name in the text box.

    5. Select the Include report creation date check box.

    6. Select the default date and time format from the selection list. The Properties pane on the right looks as follows.

  5. Save the report setup file.

Open the Simulink Model

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

The following statement in the Evaluate MATLAB Expression component that you created in Add MATLAB Code tries to open the slrgex_vdp model:

try
   open_system(expModel);
end

Tip

Select the Eval component in the Outline pane on the left to look at this code again.

To see if the slrgex_vdp model was successfully opened, test the result of the open_system command using a Logical If component.

  1. In the Outline pane on the left, select the Title Page component.

  2. In the Library pane in the middle, under the Logical and Flow Control category, select Logical If. This component checks to see if a given condition is true or false; in this case, if the model opened successfully.

  3. In the Properties pane on the right, click the icon next to Add component to current report. The Logical If component appears as if in the Outline pane.

    These components are child components of the report and siblings of one another. Components can have parent, child, and sibling relationships.

    This component can have child components. Add Logical Then and Logical Else Components explains how to add two child components to the if component.

  4. In the Properties pane on the right, in the Test expression text box, replace the default text, true, with the following text:

    strcmp(bdroot(gcs),expModel)
    The strcmp function compares the name of the open Simulink model and the value of expModel, which was set to 'slrgex_vdp'. It tests to see if the slrgex_vdp model opened successfully. strcmp returns 1 (true) if the two strings match, and 0 (false) if not.

  5. Save the report setup file.

    The if component name in the Outline pane changes to include the expression that you added.

Add Logical Then and Logical Else Components

Note

This section builds on the previous tasks.

To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

The if strcmp(bdroot(gcs), expModel) component has two possible results. Add two child components to the report setup file to process these cases.

  1. In the Outline pane on the left, select the if component.

  2. In the Library pane in the middle, under the Logical and Flow Control category, double-click Logical Then.

  3. In the Outline pane on the left, select the if component again.

  4. In the Library pane in the middle, under the Logical and Flow Control category, double-click Logical Else.

    Both elements are added as child components to the if component, as shown in the Outline pane.

  5. To move the else component under the then component, select the else component and click the down arrow on the toolbar once. The Outline pane on the left looks as follows.

  6. Save the report setup file.

Error If Model Cannot Be Opened

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

If the if strcmp(bdroot(gcs), expModel) component fails (the slrgex_vdp model cannot open), the else component executes. Display an error message in the report using the Chapter/Subsection component.

  1. In the Outline pane on the left, select the else component.

  2. In the Library pane in the middle, under the Formatting category, double-click Chapter/Subsection to add it as a child of the else component. This component displays an error message if an error occurs when opening the slrgex_vdp model.

    Note

    When you add a component to a report, it is added by default as a child component unless the selected component cannot have child components.

  3. In the Properties pane on the right, choose Custom from the Title selection list, and then enter the following text in the text box:

    Load Model Failed.

    Save the report file.

    The Outline pane looks as follows.

  4. In the Outline pane on the left, select the Chapter component.

  5. In the Library pane in the middle, under Formatting, double-click Paragraph.

  6. In the Properties pane on the right, enter the following text in the Paragraph Text text box to display the following error message:

    Error: Model %<expModel> could not be opened.
    The expression %<expModel> indicates that the value of the workspace variable expModel is inserted into the text, as in the following example.
    Error: Model slrgex_vdp could not be opened.

  7. In the Outline pane on the left, select the Chapter.

  8. Save the report setup file.

    The Outline pane looks as follows.

Create the Body of the Report

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

Creating the body of the report involves setting up components and code for dynamic execution of report components. In this example, you perform the following tasks:

Each action requires a separate component under the then component. For information about the then component in this report, see Add Logical Then and Logical Else Components.

Process with a Model Loop Component

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

The report changes the Gain parameter for the Mu block in the slrgex_vdp model several times. This task requires a Model Loop component.

  1. In the Outline pane on the left, select the then component.

  2. In the Library pane in the middle, scroll down to the Simulink category, and then double-click Model Loop. It is added as a child of the then component.

    The Properties pane on the right looks as follows.

  3. In the Properties pane on the right:

    1. Select the Active check box to process the slrgex_vdp model.

    2. In the Traverse model selection list, select Selected system(s) only to traverse only the slrgex_vdp model.

    3. Select Model root from the Starting system(s) selection list.

    4. At the bottom of the Properties pane on the left, select the Create section for each object in loop check box to create a chapter or section for each model. When you select this check box, the component name in the Outline pane on the left changes to Model Loop Chapter.

    5. Select the Display the object type in the section title check box to include the object type (in this example, model) in the title name.

    6. Clear the Create link anchor for each object in loop check box.

  4. Save the report setup file.

Add a Paragraph for Each Model

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

In each Model Loop Chapter, add an explanation using the Paragraph component.

  1. In the Outline pane on the left, select the Model Loop Chapter component.

  2. In the Library pane in the middle, scroll up to the Formatting category, and then double-click Paragraph. The Paragraph component is added as a child of the Model Loop Chapter component.

  3. In the Properties pane on the right, in the Paragraph Text text box, enter the following text:

    This report demonstrates Simulink Report Generator's ability
    to experiment with Simulink systems and auto-document
    the results. In this report, you load the model %<expModel>
    and simulate it %<length> times. This report modifies the
    %<expBlock> block's "%<expParam>" value, setting it to the 
    values %<expValue>. Each iteration of the test includes 
    a set of scope snapsnots in the report.
    When this report is generated, the variable names, preceded by percent signs (%) and enclosed in angle brackets (<>), are replaced with the values of those variables in the MATLAB workspace.

  4. Save the report setup file.

Insert a Snapshot of the Model

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

Inside each Model Loop Chapter component, include a snapshot of the current model using the System Snapshot component.

  1. In the Outline pane on the left, select the Model Loop Chapter component.

  2. In the Library pane in the middle, scroll down to the Simulink category, and then double-click the System Snapshot component.

    This component inserts an image of the current model into your report. The Properties pane on the right looks as follows.

  3. In the Properties pane on the right:

    1. Select Zoom from the Scaling selection list.

    2. Enter 70 as the % value.

  4. In the Outline pane on the left, select the System Snapshot component.

  5. Click the down arrow on the toolbar once to move it under the Paragraph component.

  6. Save the report setup file.

Add a Loop for Processing the Model

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

Create a loop to process the model %length times using the For Loop component.

  1. In the Outline pane on the left, select the System Snapshot component.

  2. In the Library pane in the middle, under the Logical and Flow Control category, double-click For Loop. The For Loop component is added as a sibling of the System Snapshot component.

  3. In the Properties pane on the right:

    1. In the End text box, replace the existing text with the following text:

      length(expValue)
      expValue is the array of Gain parameter values assigned in the Eval component with the command expValue=[-1 0 0.5 1 2];. The expression length(expValue) evaluates to 5 in this example.

    2. In the Variable name text box, replace the existing text with the name of the for loop variable. Enter the following text:

      expIteration
      The name of the For component in the Outline pane on the left changes to reflect the loop variable and the termination value.

  4. Save the report setup file.

Block Parameter Value from a MATLAB Expression

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

For each iteration, get a value from the expValue array to use as the Gain parameter value. This task requires an Evaluate MATLAB Expression component.

  1. In the Outline pane on the left, select the for component.

  2. In the Library pane in the middle, under the MATLAB category, double-click Evaluate MATLAB Expression. In the Outline pane, the component name is shortened to Eval.

  3. On the Properties pane on the right:

    1. Clear the Insert MATLAB expression in report and Display command window output in report check boxes.

    2. Enter the following text in the Expression to evaluate in the base workspace text box:

      %Evaluate this string in the base workspace
      
      if iscell(expValue)
         Iteration_Value=expValue{expIteration};
      else
        Iteration_Value=...
           num2str(expValue(expIteration));
      end
      The Iteration_Value variable represents the designated array element.

    3. Clear the Evaluate this expression if there is an error check box.

  4. Save the report setup file.

Create a Section for Each Iteration

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

Create a separate section for each iteration of the loop that includes the data using the Chapter/Subsection component.

  1. In the Outline pane on the left, under the for component, select the Eval component.

  2. In the Library pane in the middle, under the Formatting category, double-click Chapter/Subsection to add it as a sibling. This component is automatically added as Section 1 because it is inside a Chapter component (the Model Loop Chapter component).

  3. In the Properties pane on the right:

    1. In the Title selection list, select Custom.

    2. In the text box, enter the following title:

      Processing the slrgex_vdp model

    This indicates that the section title comes from the first child component. Do not change any other properties.

  4. Save the report setup file.

Insert the Block Value

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

Insert the Gain value that is used for each simulation.

  1. In the Outline pane on the left, select the Section 1 component.

  2. In the Library pane in the middle, under the MATLAB category, double-click Insert Variable.

  3. In the Properties pane on the right:

    1. In the Variable name text box, enter Iteration_Value.

    2. In the Display as selection list, select Paragraph.

    The Properties pane on the right looks as follows.

  4. Save the report setup file.

Set a Parameter Value

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

For each iteration, set the Gain parameter to the value that you extracted from the expValue array.

  1. In the Outline pane on the left, select the Variable component.

  2. In the Library pane in the middle, under the MATLAB category, double-click Evaluate MATLAB Expression. This component is added as a sibling of the Variable component.

  3. In the Properties pane on the right, clear the Insert MATLAB expression in report and Display command window output in report check boxes.

  4. In the Expression to evaluate in the base workspace text box, replace the existing text with the following text.

    set_param(expBlock,expParam,Iteration_Value);
    okSetValue=(1);
    The set_param command sets the value of the Gain parameter for the Mu block in the slrgex_vdp model to the value of Iteration_Value.

  5. Make sure you select Evaluate this expression if there is an error. Enter the following text into the text box:

    okSetValue=logical(0);
    If the set_param command works, okSetValue is set to 1. If an error occurs, okSetValue is set to 0. The next component then reports the error and terminates processing.

  6. Save the report setup file.

    The Outline pane on the left looks as follows.

Check Value Using a Logical If Component

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

Check the value of okSetValue using a Logical If component. If the value is 0, the simulation cannot proceed because the Gain parameter could not be set.

  1. In the Outline pane on the left, select the Eval component for the set_param command.

  2. In the Library pane in the middle, under the Logical and Flow Control category, double-click Logical If. The component is added as a sibling of Eval.

  3. In the Properties pane on the right, in the Test expression text box, replace true with okSetValue.

okSetValue can be 1 (true) or 0 (false), so insert two components — Logical Then and Logical Else — to process those conditions:

  1. In the Outline pane on the left, select the if (okSetValue) component.

  2. To insert Logical Then and Logical Else in the correct order:

    1. In the Library pane in the middle, double-click the Logical Else component.

    2. Select the if (okSetValue) component again.

    3. Double-click the Logical Then component. The Outline pane on the left looks as follows.

  3. In the Outline pane on the right, select the else component.

  4. In the Library pane in the middle, double-click Paragraph.

    If okSetValue = 0, the Gain parameter value is not set and the report displays an error.

  5. In the Properties pane on the right:

    1. Choose Custom title from the Title Options selection list.

    2. Enter Error in the text box next to the selection list.

    3. Enter the following text into the Paragraph Text text box:

      Could not set %<expBlock> "%<expParam>" to value 
      %<Iteration_Value>.

  6. Save the report.

Simulate the Model Using a Model Simulation Component

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

Now that the model is open and the Gain parameter is set, use the Model Simulation component to simulate the slrgex_vdp model.

  1. In the Outline pane on the left, select the then component under the if (okSetValue) component.

  2. In the Library pane, under the Simulink category, double-click Model Simulation. In the Outline pane on the left, this component is renamed Simulate model.

  3. In the Properties pane on the right:

    1. Clear the Use model's workspace I/O variable names check box.

    2. In the Time text box, enter dynamicT.

    3. In the States text box, enter dynamicX.

    4. In the Output text box, enter dynamicY.

    The Properties pane on the right looks as follows.

  4. In the Outline pane on the left, select the Simulate model component.

  5. In the Library pane in the middle:

    1. Scroll down to the Simulink Blocks category.

    2. Double-click Scope Snapshot to add it as a sibling of the Simulink Model component.

    This component captures the scope for each iteration.

  6. In the Properties pane on the right:

    1. In the Paper orientation selection list, select Portrait.

    2. For the Image size, enter [5 4].

    3. In the Scaling selection list, select Zoom.

    4. Enter 75 for the % value.

  7. Save the report setup file.

  8. To test to see if the signal data falls within a specified range, add another Logical If component:

    1. In the Outline pane on the left, select the Scope Snapshot component.

    2. In the Library pane in the middle, scroll up to the Logical and Flow Control category.

    3. Double-click the Logical If component.

  9. To test the signal data, replace true in the Test expression text box with the following in the Properties pane on the right:

    max(dynamicX(:,2))>testMin & max(dynamicX(:,2))<testMax

  10. Save the report.

    The Outline pane looks as follows:

  11. If this condition is true, the signal data falls within the desired range. Add a Paragraph component to print information about the signal data in the report.

    1. In the Outline pane on the left, select the if component you just added.

    2. In the Library pane in the middle, under the Formatting category, double-click Paragraph so that it becomes a child of the if component.

    3. In the Properties pane on the right:

      1. From the Title Options selection list, select Custom title.

      2. Type Success in the text box.

      3. Enter the following text in the Paragraph text text box.

        The conditioned signal has a maximum value
        of %<max(dynamicX(:,2))>, which lies in the
        desired range of greater than %<testMin> and
        less than %<testMax>.

  12. To save the success values to insert into a table at the end of the iterations, use an Evaluate MATLAB Expression component.

    1. In the Outline pane on the left, select the Paragraph component.

    2. In the Library pane in the middle, under the MATLAB category, double-click Evaluate MATLAB Expression.

      An unintended result occurs: the new component is a child of the Paragraph component.

    3. To make the new component a sibling of the Paragraph component, in the Outline pane on the left, select the Eval component, and then Click the left arrow on the toolbar. The Eval component becomes a sibling of the Paragraph component.

  13. In the Properties pane on the right, for the Eval component:

    1. Clear the Insert MATLAB expression in report and Display command window output in report check boxes.

    2. In the Expression to evaluate in the base workspace text box, enter the following to save the desired signal values in the expOkValues array:

      expOkValues=[expOkValues;...
           {Iteration_Value,max(dynamicX(:,2))}];

    3. Make sure you select Evaluate this expression if there is an error. Insert the following text in the text box:

      disp(['Error during eval: ', evalException.message])

  14. Save the report setup file.

Create a Post-Test Analysis Section

Note

This section builds on the previous tasks. To see the completed report setup file, open the simulink-dynamic.rpt setup file.

setedit simulink-dynamic.rpt
The report is for the slrgex_vdp model.

Now that you have collected all the desired values, create the post-test analysis section by creating a table and inserting it into your report at the end of this chapter.

  1. In the Outline pane on the left, select the Model Loop Chapter component.

  2. In the Library pane in the middle, under the Formatting category, double-click Chapter/Subsection.

    The new section appears at the beginning of the chapter.

    Click the down arrow three times so Section 1 moves to the end of the Model Loop Chapter component.

  3. In the Properties pane on the right:

    1. Select Custom in the Title selection list.

    2. Enter Post-Test Analysis in the text box.

  4. In the Outline pane on the left, select the new Section 1 component.

  5. In the Library pane in the middle, under the Formatting category, double-click Paragraph. Do not change its properties.

  6. To check whether there are any signal values within the desired range, check the array expOkValues with a Logical If component. If expOkValues is empty, there are no signal values in the desired range. Report the result of this check.

    1. In the Outline pane on the left, select the Paragraph component and add a Logical If child component.

    2. In the Properties pane on the right, enter the expression to evaluate in the Test expression text box:

      ~isempty(expOkValues)
      This expression evaluates to 0 (false) if expOkValues is empty; otherwise, it evaluates to 1 (true).

    3. In the Outline pane on the left, select the if (~isempty(expOkValue)) component and add the Logical Else component as a child.

    4. Select the if(~isempty(expOkValue)) component again and add the Logical Then component as a child.

      The two components are siblings in the Outline pane on the left.

  7. Save the report setup file.

  8. Now, insert report components to handle the case where expOkValues is empty; that is, where no signal values fall within the designated range.

    1. In the Outline pane on the left, select the else component.

    2. In the Library pane in the middle, double-click the Text component to add it as a child of the else component.

    3. In the Properties pane on the right, in the Text to include in report text box, enter the following:

      None of the selected iteration values had 
      a maximum signal value between %<testMin> and %<testMax>.

  9. Now handle the case where expOkValues is not empty and you want to insert a table of the acceptable signal values.

    1. In the Outline pane on the left, select the then component.

    2. Add a Text component as a child to the then component.

    3. In the Properties pane on the right, in the Text to include in report text box, enter the following text.

      %<size(expOkValues, 1)> values for %<expBlock> were 
      found that resulted in a maximum signal value greater
      than %<testMin> but less than %<testMax>. The following
      table shows those values and their resulting signal maximum.

    4. In the Outline pane on the left, select the Text component under the then component of the if (~isempty(expOkValues)) component.

  10. To create an array for use when formatting the table, use the Evaluate MATLAB Expression component.

    1. In the Library pane in the middle, double-click Evaluate MATLAB Expression.

    2. In the Properties pane on the right:

      1. Clear the Insert MATLAB expression in report and Display command window output in report check boxes.

      2. The next component of the report uses the strings Mu Value and Signal Maximum as table header values. Add the strings to the front of the expOkValues cell array by entering the following text into the Expression to evaluate in the base workspace text box:

        expOkValues=[{'Mu Value','Signal Maximum'} expOkValues];

      3. Make sure you select the Evaluate this expression if there is an error check box. Enter the following text into the text box:

        disp(['Error during eval: ', evalExpression.message])

  11. In the Outline pane on the left, select the Eval component.

  12. In the Library pane in the middle, under the Formatting category, double-click the Array-Based Table component so it becomes a sibling of the Text and Eval components.

  13. In the Properties pane on the right:

    1. In the Workspace variable name text box, enter expOkValues. The Simulink Report Generator software uses the contents of expOkValues to construct the table.

    2. In the Table title text box, enter Valid Iteration Values.

  14. Save the report setup file.

    The Outline pane on the left looks as follows.

Generate the Report

To generate the report, click the Report icon on the toolbar. The following occurs:

  1. A Message List window appears, displaying informational and error messages as the report is processed. Specify the level of detail you would like the Message List window to display while the report is being generated. Options range from 0 (least detail) to 6 (most detail). Click the selection list located under the title bar of the Message List window to choose an option.

    Message level 3 (Important messages) is used for the remainder of this example.

  2. The slrgex_vdp model appears. You can see each time it is simulated.

  3. The scope window appears. The scope graph changes each time the parameter value changes.

  4. Each component of the report is highlighted as it executes, in the Outline pane on the left in the Report Explorer window.

When the report generation is complete, the report opens.