User`s guide
25 Create Model Advisor Checks
25-6
Quick Start Examples
In this section...
“Add Customized Check to By Product Folder” on page 25-6
“Create Customized Pass/Fail Check” on page 25-7
“Create Customized Pass/Fail Check with Fix Action” on page 25-11
Add Customized Check to By Product Folder
The following example shows how to add a customized check to a Model Advisor By
Product > Demo subfolder. In this example, the customized check does not check model
elements.
1
In your working directory, create the sl_customization.m file, as
shown below. This file registers and creates the check registration function
defineModelAdvisorChecks, which in turn registers the check callback
function SimpleCallback. The function defineModelAdvisorChecks uses a
ModelAdvisor.Root object to define the check interface.
function sl_customization(cm)
% --- register custom checks
cm.addModelAdvisorCheckFcn(@defineModelAdvisorChecks);
% --- defineModelAdvisorChecks function
function defineModelAdvisorChecks
mdladvRoot = ModelAdvisor.Root;
rec = ModelAdvisor.Check('exampleCheck');
rec.Title = 'Example of a customized check';
rec.TitleTips = 'Added customized check to Product Folder';
rec.setCallbackFcn(@SimpleCallback,'None','StyleOne');
mdladvRoot.publish(rec, 'Demo');
% --- creates SimpleCallback function
function result = SimpleCallback(system);
result={};
2
Close the Model Advisor and your model if either are open.
3
In the Command Window, enter:
sl_refresh_customizations
4
From the MATLAB window, select New > Model to open a new Simulink model
window.