Documentation Center

  • Trial Software
  • Product Updates

Contents

Create a Procedural-Based Configuration

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

  1. At the MATLAB® command line, type slvnvdemo_mdladvslvnvdemo_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, selectAnalysis > 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. It might take a few minutes to open.

  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 to Failure. 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 is dependent 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 to Failure. 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 to Failure. 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.

Was this topic helpful?