Main Content

ModelAdvisor.Task

R2026b

Define custom tasks in Model Advisor tree

Description

Use ModelAdvisor.Task class to create a wrapper for a custom check, enabling access to the check within the Model Advisor tree.

Note

You can use one ModelAdvisor.Check object in multiple ModelAdvisor.Task objects, allowing you to place the same check in multiple locations in the Model Advisor tree. For example, Check for implicit signal resolution appears in the By Product > Simulink folder and in the By Task > Model Referencing folder in the Model Advisor tree.

Creation

Description

taskObj = ModelAdvisor.Task(taskID) creates a task object with the unique identifier taskID, which serves as a wrapper for a custom check within the Model Advisor tree.

example

Input Arguments

expand all

Unique identifier for the Model Advisor task.

Data Types: char

Output Arguments

expand all

Wrapper for a custom check to display in the Model Advisor tree, returned as a ModelAdvisor.Task object.

Properties

expand all

Description of the task that the Model Advisor displays, specified as a string scalar or character vector.

Example: "Example Task is as shown:"

Data Types: char | string

Name of the task in the Model Advisor, specified as a string scalar or character vector.

Example: "Task 1"

Data Types: char | string

Task selection status, specified as a numeric or logical 1 (true) or 0 (false). If Enable is 1, the task is selected and included in the Model Advisor analysis, with its checkbox marked in the Model Advisor tree. If Enable is 0, the task is deselected, its checkbox is cleared, and it is excluded from the analysis.

Data Types: logical

Task identifier, specified as a string scalar or character vector.

Note

  • The Model Advisor automatically assigns a unique identifier to ID if you do not specify it.

  • The value of ID must remain constant.

  • The Model Advisor generates an error if ID is not unique.

  • Group definitions must refer to tasks using ID.

Example: "Task_ID_1234"

Data Types: char | string

Cell array of product license names required to display and run the checks in the task.

Tip

To find the text for license strings, type help license in the MATLAB® command line.

Example: {"Simulink®"}

Current Model Advisor object specified for the task or check, specified as Simulink.ModelAdvisor object.

Initial task, specified as a numeric or logical 1 (true) or 0 (false). If Enable is 1, the task is enabled initially. If Enable is 0, the task is disabled initially.

Data Types: logical

Task display indication in the Model Advisor, specified as a numeric or logical 1 (true) or 0 (false). If Enable is 1, the task is displayed in the Model Advisor. If Enable is 0, the task is hidden in the Model Advisor.

Caution

When adding checks as tasks, you cannot specify both the task and check Visible properties, you must specify one or the other. If you specify both properties, the Model Advisor generates an error when the check Visible property is false.

Data Types: logical

Object Functions

setCheckSpecify check used in Model Advisor task

Examples

collapse all

This example shows how to add a task to Model Advisor tree.

Create a unique task ID and assign it to a task object.

taskID = "com.mathworks.sample.Task1";
taskObj = ModelAdvisor.Task(taskID);

Set the task properties.

taskObj.DisplayName = "Sample Task";
taskObj.Description = "This task runs a custom check as part of the Model Advisor analysis.";
taskObj.Enable = true;

Add a check to the task.

checkID = "com.mathworks.sample.Check1";
setCheck(taskObj,checkID);

Version History

Introduced in R2006a