Main Content


Specify callback function for check


setCallbackFcn(check_obj, @handle, context, style)


setCallbackFcn(check_obj, @handle, context, style) specifies the callback function to use with the check, check_obj.

For the style input argument, to use the default format of the Model Advisor report, specify DetailStyle. With the default format, you do not have to use the ModelAdvisor.FormatTemplate class or the other Model Advisor Formatting APIs to format the results that appear in the Model Advisor. DetailStyle also allows you to view results by block, subsystem, or recommended action. If the default formatting does not meet your needs, use the ModelAdvisor.FormatTemplate API or the other formatting APIs.

Input Arguments


Instantiation of the ModelAdvisor.Check class


Handle to a check callback function


Context for checking the model or subsystem:

  • 'None' — No special requirements.

  • 'PostCompile' — The model must be compiled.

  • 'PostCompileForCodegen'— The model is compiled for code generation but is not simulated. Use this option to check the code generation readiness of a model and to analyze both active and inactive variant paths. To analyze both active and inactive variants, you must set the System target file configuration parameter to ert.tlc.


Type of callback function:

  • 'StyleOne' — Simple check callback function, for formatting results using template

  • 'StyleTwo' — Detailed check callback function

  • 'StyleThree' — Check callback functions with hyperlinked results

  • 'DetailStyle' — Check callback function for result collections. This style is recommended for authoring Model Advisor checks.


This example illustrates the definition for a check using a callback function whose style is defined as DetailStyle.

% This is the recommended style to author checks. 
function defineModelAdvisorChecks
mdladvRoot = ModelAdvisor.Root;
rec = ModelAdvisor.Check('com.mathworks.sample.Check0');
rec.Title = 'Check whether block names appear below blocks (recommended check style)';
rec.TitleTips = 'Example new style callback (recommended check style)';
% set fix operation
myAction0 = ModelAdvisor.Action;
myAction0.Name='Make block names appear below blocks';
myAction0.Description='Click the button to place block names below blocks';
mdladvRoot.publish(rec, 'Demo'); % publish check into Demo group.