メインコンテンツ

ModelAdvisor.Action

R2026b

Action added to custom checks

Description

Use ModelAdvisor.Action objects to define custom action that are triggered when Model Advisor custom checks do not pass.

Creation

Description

action = ModelAdvisor.Action creates a default action object for use in the Model Advisor output.

Note

  • Include an action definition in a check definition.

  • Each check can contain only one action.

example

Properties

expand all

Label for the action button, specified as a string scalar or character vector.

Example: "Fix issue"

Data Types: char | string

Tooltip message that appears when you hover over the action button in the Model Advisor results pane, specified as a string scalar or character vector.

Example: "Click the button to update all blocks with specified font"

Data Types: char | string

Object Functions

setCallbackFcnDefine action callback function

Examples

collapse all

Create a ModelAdvisor.Action object, set its properties, and define a callback function to provide a Fix 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"; 
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

Version History

Introduced in R2006b