| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Use instances of this class in M-file programs to run the Model Advisor, for example, to perform a standard set of checks. MATLAB software creates an instance of this object for each model that you open in the current MATLAB session. To get a handle to a model's Model Advisor object, execute the following command
ma = Simulink.ModelAdvisor.getModelAdvisor(model);
where model is the name of the model or subsystem that you want to check. Your program can then use the Model Advisor object's methods to initialize and run the Model Advisor's checks.
Many Simulink.ModelAdvisor object methods require or return IDs. An ID is a string that identifies a Model Advisor check, task, or group. ID must remain constant. A Simulink.ModelAdvisor object includes methods that enable you to retrieve the ID or IDs for all checks, tasks, and groups, checks belonging to groups and tasks, the active check, and selected checks, tasks and groups. See the Simulink.ModelAdvisor Method Summary for more information.
You can also determine check IDs as follows:
In the Model Advisor, select View > Source Tab.
Navigate to the folder that contains the check.
In the right pane, click Source. The Model Advisor displays the Title, TitleID, and Source information for each check in the folder.
ma = Simulink.ModelAdvisor
Name | Description |
|---|---|
Close Model Advisor report. | |
Deselect checks. | |
Deselect all checks. | |
Deselect a group of checks. | |
Deselect checks that belong to a specified task or set of tasks. | |
Deselect tasks. | |
Deselect all tasks. | |
Display Model Advisor report. | |
Copy report to a specified location. | |
Get baseline mode setting for the Model Advisor. | |
Get the IDs of the checks performed by the Model Advisor. | |
Get checks belonging to a check group. | |
Get checks belonging to a task. | |
Get check results. | |
Get check result data. | |
Get pass/fail status of a check or set of checks. | |
Get the IDs of the groups of tasks performed by the Model Advisor. | |
Get input parameters of a check. | |
Get list view parameters of a check. | |
Get the Model Advisor for a model or subsystem. | |
Get selected checks. | |
Get path of system currently targeted by the Model Advisor. | |
Get selected tasks. | |
Get the IDs of the tasks performed by the Model Advisor. | |
| Start the Model Advisor Configuration editor. | |
Determine whether a report exists for a system or subsystem. | |
Run selected checks. | |
Run checks for selected tasks. | |
Select checks. | |
Select all checks. | |
Select a group of checks. | |
Select checks that belong to a specified task. | |
Select tasks. | |
Select all tasks. | |
Set enable/disable status for a check action. | |
Set baseline mode for the Model Advisor. | |
Set severity of a check failure. | |
Set result for the currently running check. | |
Set result data for the currently running check. | |
Set pass/fail status for the currently running check. | |
Set list view parameters for a check. | |
Verify that checks have run. | |
Generate a baseline set of check results or compare the current set of results to the baseline results. | |
Verify that a model has passed or failed a set of checks. | |
Generate a baseline report or compare the current report to a baseline report. |
Close Model Advisor report.
closeReport
Closes the report associated with this Model Advisor object, which closes the Model Advisor window.
Deselect a check.
success = deselectCheck(ID)
String or cell array that specifies the IDs of the checks to be deselected
True (1) if the check is deselected.
This method deselects the checks specified by ID.
getCheckAll, deselectCheckForGroup, selectCheck
Deselect all checks.
success = deselectCheckAll
Deselects all checks that are not disabled.
Deselect a group of checks.
success = deselectCheckForGroup(groupName)
String or cell array that specifies the names of the groups to be deselected
True (1) if the method succeeds in deselecting the specified group.
Deselects a specified group of checks.
Deselect checks that belong to a specified task or set of tasks.
success = deselectCheckForTask(ID)
String or cell array of strings that specify the IDs of tasks whose checks are to be deselected.
True (1) if the specified tasks are deselected.
Deselects checks belonging to the tasks specified by the ID argument.
getTaskAll, selectCheckForTask
Deselect a task.
success = deselectTask(ID)
String or cell array that specifies the ID of tasks to be deselected
True (1) if the method succeeded in deselecting the specified tasks
Deselects the tasks specified by ID.
Deselect all tasks.
success = deselectTaskAll
Deselects all tasks.
Display report in Model Advisor.
displayReport
Displays the report associated with this Model Advisor object in the Model Advisor window. The report includes the most recent results of running checks on the system associated with this Model Advisor object and the current selection status of checks, groups, and tasks for the system.
Simulink.ModelAdvisor.reportexists
Create a copy of a report generated by Model Advisor.
[success message] = exportReport(destination)
Path name of copy to be made of the report file.
True (1) if this method succeeded in creating a copy of the report at the specified location.
empty if the copy was successful; otherwise, the reason the copy did not succeed.
This method creates a copy of the last report generated by the Model Advisor and stores the copy at the specified location.
Simulink.ModelAdvisor.reportexists
Determine whether the Model Advisor is in baseline data generation mode.
mode = getBaselineMode
The mode output variable returns true if the Model Advisor is in baseline data mode. Baseline mode causes the Model Advisor's verification methods, e.g., verifyHTML, to generate baseline data.
setBaselineMode, verifyHTML, verifyCheckResult, verifyCheckResultStatus
Get the IDs of all checks.
IDs = getCheckAll
Returns a cell array of strings specifying the IDs of all checks performed by the Model Advisor.
Get checks that belong to a check group.
IDs = getCheckForTask(groupName)
Returns a cell array of IDs of the tasks belonging to the group specified by groupName.
Get the checks that belong to a task.
checkIDs = getCheckForTask(taskID)
Returns a cell array of IDs of the checks belonging to the task specified by taskID.
Get the results of running a check or set of checks.
result = getCheckResult(ID)
Gets results for the specified checks. The format of the results depends on the checks that generated the data.
Note This method is intended for accessing results generated by custom checks created with the Model Advisor's customization API, an optional feature available with Simulink® Verification and Validation™ software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
getCheckResultData, getCheckResultStatus
Get the data resulting from running a check or set of checks.
result = getCheckResultData(ID)
Check ID or cell array of check IDs
Data from a check result or cell array of data from check results
Gets the check result data for the specified checks. The format of the data depends on the checks that generated the data.
Note This method is intended for accessing check result data generated by custom checks created with the Model Advisor's customization API, an optional feature available with Simulink Verification and Validation software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
getCheckResult, getCheckResultStatus
Get the pass/fail status of a check or set of checks.
result = getCheckResultStatus(ID)
Check ID or cell array of check IDs
Boolean or a cell array of Boolean values indication the pass/fail status of a check or set of checks
Invoke this method after running a set of checks to determine whether the checks passed or failed.
getCheckResult, getCheckResultData
Get all groups of checks performed by the Model Advisor.
IDs = getGroupAll
Returns a cell array of IDs of all groups of checks performed by the Model Advisor.
Get input parameters of a check.
params = obj.getInputParameters(check_ID)
A string that uniquely identifies the check.
You can omit the check_ID if you use the method inside a check callback function.
Returns the input parameters associated with a check.
Note This method is intended for accessing custom checks created with the Model Advisor's customization API, an optional feature available with Simulink Verification and Validation software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
Get list view parameters of a check.
params = obj.getListViewParameters(check_ID)
A cell array of ModelAdvisor.ListViewParameter objects.
A variable representing the Simulink.ModelAdvisor object.
A string that uniquely identifies the check.
You can omit the check_ID if you use the method inside a check callback function.
Returns the list view parameters associated with a check.
Note This method is intended for accessing custom checks created with the Model Advisor's customization API, an optional feature available with Simulink Verification and Validation software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
setListViewParameters, ModelAdvisor.ListViewParameter
Get a Model Advisor object for a system or subsystem.
obj = Simulink.ModelAdvisor.getModelAdvisor(system)
obj = Simulink.ModelAdvisor.getModelAdvisor(system,
'new')
Name of model for which the Model Advisor is to be gotten
Required when changing Model Advisor working scope from one system to another without closing the previous session. Alternatively, you can close the previous session before invoking getModelAdvisor, in which case 'new' can be omitted.
Model Advisor object
This static method (see Static Methods) creates and returns an instance of Simulink.ModelAdvisor class for the model or subsystem specified by system.
Get the currently selected checks.
IDs = getSelectedCheck
Returns the checks currently selected in the Model Advisor.
Get system currently targeted by the Model Advisor.
path = getSelectedSystem
Gets the path of the system currently targeted by the Model Advisor, i.e., the system or subsystem most recently selected for checking either interactively by the user or programmatically via Simulink.ModelAdisor.getModelAdvisor.
Get selected tasks.
IDs = getSelectedTask
Returns the tasks currently selected in the Model Advisor.
Get the tasks performed by the Model Advisor.
IDs = getTaskAll
Returns a cell array of IDs of tasks performed by the Model Advisor.
Starts the Model Advisor Configuration editor.
Simulink.ModelAdvisor.openConfigUI
This static method starts the Model Advisor Configuration editor. Use the Model Advisor Configuration editor to create customized configurations for the Model Advisor.
Note The Model Advisor Configuration editor is an optional feature available with Simulink Verification and Validation software (see Creating Custom Configurations by Organizing Checks and Folders in the online Simulink Verification and Validation documentation for more information).
|
Determine whether a report exists for a model or subsystem.
exists = reportexists('system')
String specifying path name of a system or subsystem
True (1) if a report exists for system
This method returns true (1) if a report file exists for the model (system) or subsystem specified by system in the slprj/modeladvisor subdirectory of the MATLAB working directory.
Run the currently selected checks.
success = runCheck
Runs the checks currently selected in the Model Advisor. Invoking this method is equivalent to selecting the Run Advisor button on the Model Advisor window.
Run the currently selected tasks.
success = runTask
Runs the tasks currently selected in the Model Advisor. Invoking this method is equivalent to selecting the Run Selected Checks button on the Model Advisor window.
Select a check.
success = selectCheck(ID)
ID or cell array of IDs of checks to be selected
True (1) if this method succeeded in selecting the specified checks
This method cannot select a check that is disabled.
selectCheckAll, selectCheckForGroup, deselectCheck
Select all checks.
success = selectCheckAll
Selects all checks that are not disabled.
selectCheck, selectCheckForGroup, deselectCheck
Select a group of checks.
success = selectCheckForGroup(ID)
ID or cell array of group IDs
True (1) if this method succeeded in selecting the specified groups
Selects the groups specified by ID.
Select checks that belong to a specified task or set of tasks.
success = selectCheckForTask(ID)
ID or cell array of IDs of tasks whose checks are to be selected
True (1) if this method succeeded in selecting the checks for the specified tasks
Selects checks belonging to the tasks specified by the ID argument.
Select a task.
success = selectTask(ID)
ID or cell array of IDs of the task to be selected
True (1) if this method succeeds in selecting the specified tasks
Selects a task.
Select all tasks.
success = selectTaskAll
Selects all tasks.
Set enable/disable status for check action
obj.setActionenable(value)
A variable representing the Simulink.ModelAdvisor object.
Boolean value indicating whether the Action box is enabled or disabled.
true — enable the Action box.
false — Disable the Action box.
The setActionenable method specifies the enables or disables the Action box. Only a check callback function can invoke this method.
Note This method is intended for accessing custom checks created with the Model Advisor's customization API, an optional feature available with Simulink Verification and Validation software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
Set the baseline data generation mode for the Model Advisor.
setBaselineMode(mode)
Boolean value indicating setting of Model Advisor's baseline mode, either on (true) or off (false)
Sets the Model Advisor's baseline mode to mode. Baseline mode causes the Model Advisor's verify methods to generate baseline comparison data for verifying the results of a Model Advisor run.
getBaselineMode, verifyCheckResult, verifyHTML
Set severity of a check failure.
obj.setCheckerrorSeverity(value)
A variable representing the Simulink.ModelAdvisor object.
Integer indicating severity of failure.
0 — Check Result = Warning
1 — Check Result = Failed
Sets result status for a currently running check that fails to value. Only a check callback function can invoke this method.
Note This method is intended for accessing custom checks created with the Model Advisor's customization API, an optional feature available with Simulink Verification and Validation software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
Set the result for the currently running check.
success = setCheckResult(result)
String or cell array that specifies the result of the currently running task
True (1) if this method succeeds in setting the check result
Sets the check result for the currently running check. Only the check's callback function can invoke this method.
Note This method is intended for use with custom checks created with the Model Advisor's customization API, an optional feature available with Simulink Verification and Validation software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
getCheckResult, setCheckResultData, setCheckResultStatus
Set the result data for the currently running check.
success = setCheckResultData(data)
Result data to be set
True (1) if this method succeeds in setting the result data for the current check
Sets the check result data for the currently running check. Only the check's callback function can invoke this method.
Note This method is intended for use with custom checks created with the Model Advisor's customization API, an optional feature available with Simulink Verification and Validation software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
getCheckResultData, setCheckResult, setCheckResultStatus
Set the pass/fail status for the currently running check.
success = setCheckResultStatus(status)
Boolean value that indicates the status of the check that just ran, either pass (true) or fail (false)
True (1) if the status was set.
Sets the pass/fail status for the currently running check to status. Only the check's callback function can invoke this method.
Note This method is intended for use with custom checks created with the Model Advisor's customization API, an optional feature available with Simulink Verification and Validation software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
getCheckResultStatus, setCheckResult, setCheckResultData, setCheckerrorSeverity
Specify list view parameters for a check.
obj.setListViewParameters(check_ID, params)
A variable representing the Simulink.ModelAdvisor object.
A string that uniquely identifies the check.
You can omit the check_ID if you use the method inside a check callback function.
A cell array of ModelAdvisor.ListViewParameter objects.
Set the list view parameters for the check.
Note This method is intended for accessing custom checks created with the Model Advisor's customization API, an optional feature available with Simulink Verification and Validation software (see Defining Custom Checks in the online Simulink Verification and Validation documentation for more information). |
getListViewParameters, ModelAdvisor.ListViewParameter
Verify that the Model Advisor has run a set of checks.
[success, missingChecks, additionalChecks] = verifyCheckRan(IDs)
Cell array of IDs of checks to verify
Boolean value specifying whether the checks ran
Cell array of IDs for specified checks that ran
Cell array of IDs for unspecified checks that ran
The output variable success returns true if all the checks specified by IDs have run. If not, success returns false, missingChecks lists specified checks that did not run. The additionalChecks argument lists unspecified checks that ran.
Generate a baseline Model Advisor check results file or compare the current check results to the baseline check results.
[success message] = verifyCheckResult(baseline, checkIDs)
Pathname of the baseline check results MAT-file
Cell array of check IDs.
Boolean value specifying whether the method succeeded
String specifying an error message
If the Model Advisor is in baseline mode (see setBaselineMode), this method stores the most recent results of running the checks specified by checkIDs in a MAT-file at the location specified by baseline. If the method is unable to store the check results at the specified location, it returns false in the output variable success and the reason for the failure in the output variable message. If the Model Advisor is not in baseline mode, this method compares the most recent results of running the checks specified by checkIDs with the report specified by baseline. If the current results match the baseline results, this method returnstrue as the value of the success output variable.
Note You must run the checks specified by checkIDs (see runCheck) before invoking verifyCheckResult. |
This method enables you to compare the most recent check results generated by the Model Advisor with a baseline set of check results. You can use the method to generate the baseline report as well as perform current-to-baseline result comparisons. To generate a baseline report, put the Model Advisor in baseline mode, using setBaselineMode. Then invoke this method with the baseline argument set to the location where you want to store the baseline results. To perform a current-to-baseline report comparison, first ensure that the Model Advisor is not in baseline mode (see getBaselineMode). Then invoke this method with the path of the baseline report as the value of the baseline input argument.
setBaselineMode, getBaselineMode, runCheck, verifyCheckResultStatus
Verify that a model has passed or failed a set of checks.
[success message] = verifyCheckResultStatus(baseline, checkIDs)
Array of Boolean variables
Cell array of check IDs.
Boolean value specifying whether the method succeeded
String specifying an error message
This method compares the pass/fail (true/false) statuses from the most recent running of the checks specified by checkIDs with the Boolean values specified by status. If the statuses match the baseline, this method returns true as the value of the success output variable.
Note You must run the checks specified by checkIDs (see runCheck) before invoking verifyCheckResultStatus. |
Generate a baseline Model Advisor report or compare the current report to a baseline report.
[success message] = verifyHTML(baseline)
Pathname of a Model Advisor report
Boolean value specifying whether the method succeeded
String specifying an error message
If the Model Advisor is in baseline mode (see setBaselineMode), this method stores the report most recently generated by the Model Advisor at the location specified by baseline. If the method is unable to store a copy of the report at the specified location, it returns false in the output variable success and the reason for the failure in the output variable message. If the Model Advisor is not in baseline mode, this method compares the report most recently generated by the Model Advisor with the report specified by baseline. If the current report has exactly the same content as the baseline report, this method returns true as the value of the success output variable.
This method enables you to compare a report generated by the Model Advisor with a baseline report to determine if they differ. You can use the method to generate the baseline report as well as perform current-to-baseline report comparisons. To generate a baseline report, put the Model Advisor in baseline mode. Then invoke this method with the baseline argument set to the location where you want to store the baseline report. To perform a current-to-baseline report comparison, first ensure that the Model Advisor is not in baseline mode (see getBaselineMode). The invoke this method with the path of the baseline report as the value of the baseline input argument.
setBaselineMode, getBaselineMode, verifyCheckResult
![]() | Simulink.MDLInfo.getMetadata | Simulink.ModelDataLogs | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |