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:
Review the information in Requirements for Customizing the Model Advisor.
Decide on order of changes to your model.
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®.
Optionally, author custom checks in a customization file. See Create Model Advisor Checks.
Organize the checks into procedures for a procedural-based configuration. See Create Procedural-Based Configurations.
Create procedures using the procedure API. For detailed information, see Create Procedures Using the Procedures API.
Create the custom configuration by using a customization file. See Organize Customization File Checks and Folders.
Verify the custom configuration as described in Verify and Use Custom Configurations.
Optionally, deploy the custom configurations to your users. For detailed information, see Organize and Deploy Model Advisor Checks.
Verify that models comply with modeling guidelines. For detailed information, see Run Model Checks (Simulink).
In this example, you examine a procedural-based configuration.
At the MATLAB® command line, type
In the model window, select View demo sl_customization.m.
sl_customization.m file opens in the MATLAB Editor
The file contains four checks created in the function
ModelAdvisor.Check('com.mathworks.sample.Check1') - Checks Simulink
ModelAdvisor.Check('com.mathworks.sample.Check2') - Checks Simulink
window screen color.
ModelAdvisor.Check('com.mathworks.sample.Check3') - Checks model
ModelAdvisor.Check('com.mathworks.sample.Check4') - Checks
Gain block usage.
Each check has a set of fix actions.
examine the function
API creates procedures
My Procedure and
% 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';
ModelAdvisor.Task class API creates tasks
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); MAT7 = ModelAdvisor.Task('com.mathworks.sample.TaskSample7'); MAT7.DisplayName='Check gain block usage'; MAT7.setCheck('com.mathworks.sample.Check4'); mdladvRoot.register(MAT7);
ModelAdvisor.Procedure.addTask method adds task
My Procedure and tasks
My sub_Procedure. The
ModelAdvisor.Procedure.addProcedure method adds
% 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); MAP_sub.addTask(MAT7); % Include the Sub-Procedure in the Procedure MAP.addProcedure(MAP_sub);
From the model window, select Analysis > Model Advisor > Model Advisor to open the Model Advisor.
A System Selector — Model Advisor dialog box opens. Click OK. The Model Advisor window opens.
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.
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.
In the Action section of the Model Advisor dialog box, click Fix block fonts.
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.
In the Action section of the Model Advisor dialog box, click Fix window screen color.
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.
In the Action section of the Model Advisor dialog box, click Fix model optimization settings.
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.