Main Content

setCallbackFcn

R2026b

Define action callback function

Description

setCallbackFcn(action,callbackFcn) assigns a callback function specified by callbackFcn to the Model Advisor action object action.

example

Examples

collapse all

Define a callback function to provide a Fix Issue action button in the Model Advisor output when a check does not pass.

Create a ModelAdvisor.Action object.

action = ModelAdvisor.Action;

Set the label and tooltip for the action button.

action.Name = "Fix Issue"; 
action.Description = "Automatically fix the issue detected by this check.";

Define the callback function to be executed when the button is clicked. Example callback function must be on path or in the same file for local functions.

action.setCallbackFcn(@myFixFunction);
function myFixFunction
% Your custom logic to fix the issue goes here
disp("The issue has been fixed");
end

Input Arguments

collapse all

Custom action displayed as a button in the Model Advisor output, returned as a ModelAdvisor.Action object.

Callback function to execute when the action button is clicked, specified as a function handle.

Version History

Introduced in R2006b