Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Create Procedural-Based Configurations

Overview of Procedural-Based Configurations

You can create a procedural-based configuration that allows you to specify the order in which you make changes to your model. You organize checks into procedures using the procedures API. A check in a procedure does not run until the previous check passes. A procedural-based configuration runs until a check fails, requiring you to modify the model to pass the check and proceed to the next check. Changes you make to your model to pass the checks therefore follow a specific order.

To create a procedural-based configuration, perform the following tasks:

  1. Review the information in Requirements for Customizing the Model Advisor.

  2. Decide on order of changes to your model.

  3. Identify checks that provide information about the modifications you want to make to your model. For example, if you want to modify your model optimization settings, the Check optimization settings check provides information about the settings. You can use custom checks and checks provided by MathWorks®.

  4. Optionally, author custom checks in a customization file. See Create Model Advisor Checks.

  5. Organize the checks into procedures for a procedural-based configuration. See Create Procedural-Based Configurations.

    1. Create procedures using the procedure API. For detailed information, see Create Procedures Using the Procedures API.

    2. Create the custom configuration by using a customization file. See Organize Customization File Checks and Folders.

    3. Verify the custom configuration as described in Verify and Use Custom Configurations.

  6. Optionally, deploy the custom configurations to your users. For detailed information, see Organize and Deploy Model Advisor Checks.

  7. Verify that models comply with modeling guidelines. For detailed information, see Run Model Checks (Simulink).

Create a Procedural-Based Configuration

In this example, you examine a procedural-based configuration.

  1. At the MATLAB® command line, type slvnvdemo_mdladv.

  2. In the model window, select View demo sl_customization.m. The sl_customization.m file opens in the MATLAB Editor window.

    The file contains three checks created in the function defineModelAdvisorChecks:

    • ModelAdvisor.Check('com.mathworks.sample.Check1') - Checks Simulink block fonts.

    • ModelAdvisor.Check('com.mathworks.sample.Check2') - Checks Simulink window screen color.

    • ModelAdvisor.Check('com.mathworks.sample.Check3') - Checks model optimization settings.

    Each check has a set of fix actions.

  3. In the sl_customization.m file, examine the function defineTaskAdvisor.

    • The ModelAdvisor.Procedure class API creates procedures My Procedure and My sub_Procedure:

      % Define procedures
      MAP = ModelAdvisor.Procedure('com.mathworks.sample.ProcedureSample');
      MAP.DisplayName='My Procedure';
      
      MAP_sub = ModelAdvisor.Procedure('com.mathworks.sample.sub_ProcedureSample');
      MAP_sub.DisplayName='My sub_Procedure';
    • The ModelAdvisor.Task class API creates tasks MAT4, MAT5, and MAT6. The ModelAdvisor.Task.setCheck method adds the checks to the tasks:

      % Define tasks
      MAT4 = ModelAdvisor.Task('com.mathworks.sample.TaskSample4'); 
      MAT4.DisplayName='Check Simulink block font';
      MAT4.setCheck('com.mathworks.sample.Check1');
      mdladvRoot.register(MAT4);
      
      MAT5 = ModelAdvisor.Task('com.mathworks.sample.TaskSample5'); 
      MAT5.DisplayName='Check Simulink window screen color';
      MAT5.setCheck('com.mathworks.sample.Check2');
      mdladvRoot.register(MAT5);
      
      MAT6 = ModelAdvisor.Task('com.mathworks.sample.TaskSample6'); 
      MAT6.DisplayName='Check model optimization settings';
      MAT6.setCheck('com.mathworks.sample.Check3');
      mdladvRoot.register(MAT6);
    • The ModelAdvisor.Procedure.addTask method adds task MAT4 to My Procedure and tasks MAT5 and MAT6 to My sub_Procedure. The ModelAdvisor.Procedure.addProcedure method adds My sub_Procedure to My Procedure:

      % Add tasks to procedures:
      % Add Task4 to MAP
      MAP.addTask(MAT4);
      % Now Add Task5 and Task6 to MAP_sub
      MAP_sub.addTask(MAT5);
      MAP_sub.addTask(MAT6);
      % Include the Sub-Procedure in the Procedure
      MAP.addProcedure(MAP_sub);
  4. From the model window, select Analysis > Model Advisor > Model Advisor to open the Model Advisor.

  5. A System Selector — Model Advisor dialog box opens. Click OK. The Model Advisor window opens.

  6. In the left pane, expand My Procedure > My sub_Procedure. The Check Simulink block font check is in the My Procedure folder. My sub_Procedure contains Check Simulink window screen color and Check model optimization settings.

  7. In the left pane of the Model Advisor, select My Procedure. In the right pane of the Model Advisor, click Run All. The Model Advisor Check Simulink block font check fails. The Model Advisor does not check the remaining two checks in the My sub_Procedure folder. Running the checks in the My sub_Procedure folder depends on passing the Check Simulink block font check.

  8. In the Action section of the Model Advisor dialog box, click Fix block fonts.

  9. In the left pane of the Model Advisor, select My Procedure. In the right pane of the Model Advisor, click Run All. The Check Simulink block font check passes. The Model Advisor runs the Check Simulink window screen color check. This check fails and the Model Advisor stops checking.

  10. In the Action section of the Model Advisor dialog box, click Fix window screen color.

  11. In the left pane of the Model Advisor, select My sub_Procedure. In the right pane of the Model Advisor, click Run All. The Check Simulink window screen color check passes. The Model Advisor runs the Check model optimization settings check. This check warns.

  12. In the Action section of the Model Advisor dialog box, click Fix model optimization settings.

  13. In the left pane of the Model Advisor, select Check model optimization settings. In the right pane of the Model Advisor, click Run This Task. The Check model optimization settings check passes.

See Also

| | | |

Related Topics

Was this topic helpful?