User`s guide
25 Create Model Advisor Checks
25-34
Check Definition Function
The following is an example of a function that defines the custom checks associated with
the callback functions described in “Create Callback Functions and Results” on page
25-37. The check definition function returns a cell array of custom checks to be added
to the Model Advisor.
The check definitions in the example use the tasks described in “Define Custom Tasks”
on page 26-14.
% Defines custom Model Advisor checks
function defineModelAdvisorChecks
% Sample check 1: Informational check
rec = ModelAdvisor.Check('mathworks.example.configManagement');
rec.Title = 'Informational check for model configuration management';
setCallbackFcn(rec, @modelVersionChecksumCallbackUsingFT,'None','StyleOne');
rec.CallbackContext = 'PostCompile';
mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(rec);
% Sample check 2: Basic Check with Pass/Fail Status
rec = ModelAdvisor.Check('mathworks.example.unconnectedObjects');
rec.Title = 'Check for unconnected objects';
setCallbackFcn(rec, @unconnectedObjectsCallbackUsingFT,'None','StyleOne');
mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(rec);
% Sample Check 3: Check with Subchecks and Actions
rec = ModelAdvisor.Check('mathworks.example.optimizationSettings');
rec.Title = 'Check safety-related optimization settings';
setCallbackFcn(rec, @OptmizationSettingCallback,'None','StyleOne');
% Define an automatic fix action for this check
modifyAction = ModelAdvisor.Action;
setCallbackFcn(modifyAction, @modifyOptmizationSetting);
modifyAction.Name = 'Modify Settings';
modifyAction.Description = ['Modify model configuration optimization' ...
' settings that can impact safety.'];
modifyAction.Enable = true;
setAction(rec, modifyAction);
mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(rec);
Define Check Input Parameters
With input parameters, the check author can request input from the user for a Model
Advisor check. Define input parameters using the ModelAdvisor.InputParameter
class inside a custom check function (see “Define Custom Checks” on page 25-30). You