User`s guide
Model Advisor Code Examples
25-55
The following code, when included in a check definition function, adds the Explore
Result button to the check in the Model Advisor.
rec = ModelAdvisor.Check('com.mathworks.sample.Check1');
% add 'Explore Result' button
rec.ListViewVisible = true;
The following code, when included in a check callback function, provides the information
to populate the Model Advisor Result Explorer.
mdladvObj = Simulink.ModelAdvisor.getModelAdvisor(system);
mdladvObj.setCheckResultStatus(true);
% define list view parameters
myLVParam = ModelAdvisor.ListViewParameter;
myLVParam.Name = 'Invalid font blocks'; % the name appeared at pull down filter
myLVParam.Data = get_param(searchResult,'object')';
myLVParam.Attributes = {'FontName'}; % name is default property
mdladvObj.setListViewParameters({myLVParam});
Action Definition
The following is an example of defining actions within a custom check. You must include
action definitions inside a check definition function (see “Check Definition Function” on
page 25-34).
The following code, when included in a check definition function, provides the
information to populate the Action box in the Model Advisor.
rec = ModelAdvisor.Check('mathworks.example.optimizationSettings');
% Define an automatic fix action for this check
modifyAction = ModelAdvisor.Action;
modifyAction.setCallbackFcn(@modifyOptmizationSetting);
modifyAction.Name = 'Modify Settings';
modifyAction.Description = ['Modify model configuration optimization' ...
' settings that can impact safety'];
modifyAction.Enable = true;
rec.setAction(modifyAction);
The Model Advisor, in the right pane, displays an Action box.