Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Simulink.ModelAdvisor - Run Model Advisor from M-file

Description

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.

About IDs

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:

  1. In the Model Advisor, select View > Source Tab.

  2. Navigate to the folder that contains the check.

  3. In the right pane, click Source. The Model Advisor displays the Title, TitleID, and Source information for each check in the folder.

Syntax

ma = Simulink.ModelAdvisor

Arguments

ma

A variable representing the Simulink.ModelAdvisor object you create.

Method Summary

Name

Description

closeReport

Close Model Advisor report.

deselectCheck

Deselect checks.

deselectCheckAll

Deselect all checks.

deselectCheckForGroup

Deselect a group of checks.

deselectCheckForTask

Deselect checks that belong to a specified task or set of tasks.

deselectTask

Deselect tasks.

deselectTaskAll

Deselect all tasks.

displayReport

Display Model Advisor report.

exportReport

Copy report to a specified location.

getBaselineMode

Get baseline mode setting for the Model Advisor.

getCheckAll

Get the IDs of the checks performed by the Model Advisor.

getCheckForGroup

Get checks belonging to a check group.

getCheckForTask

Get checks belonging to a task.

getCheckResult

Get check results.

getCheckResultData

Get check result data.

getCheckResultStatus

Get pass/fail status of a check or set of checks.

getGroupAll

Get the IDs of the groups of tasks performed by the Model Advisor.

getInputParameters

Get input parameters of a check.

getListViewParameters

Get list view parameters of a check.

getModelAdvisor

Get the Model Advisor for a model or subsystem.

getSelectedCheck

Get selected checks.

getSelectedSystem

Get path of system currently targeted by the Model Advisor.

getSelectedTask

Get selected tasks.

getTaskAll

Get the IDs of the tasks performed by the Model Advisor.

Simulink.ModelAdvisor.openConfigUI

Start the Model Advisor Configuration editor.

Simulink.ModelAdvisor.reportexists

Determine whether a report exists for a system or subsystem.

runCheck

Run selected checks.

runTask

Run checks for selected tasks.

selectCheck

Select checks.

selectCheckAll

Select all checks.

selectCheckForGroup

Select a group of checks.

selectCheckForTask

Select checks that belong to a specified task.

selectTask

Select tasks.

selectTaskAll

Select all tasks.

setActionenable

Set enable/disable status for a check action.

setBaselineMode

Set baseline mode for the Model Advisor.

setCheckerrorSeverity

Set severity of a check failure.

setCheckResult

Set result for the currently running check.

setCheckResultData

Set result data for the currently running check.

setCheckResultStatus

Set pass/fail status for the currently running check.

setListViewParameters

Set list view parameters for a check.

verifyCheckRan

Verify that checks have run.

verifyCheckResult

Generate a baseline set of check results or compare the current set of results to the baseline results.

verifyCheckResultStatus

Verify that a model has passed or failed a set of checks.

verifyHTML

Generate a baseline report or compare the current report to a baseline report.

Methods

closeReport

Purpose

Close Model Advisor report.

Syntax

closeReport

Description

Closes the report associated with this Model Advisor object, which closes the Model Advisor window.

See Also

displayReport

deselectCheck

Purpose

Deselect a check.

Syntax

success = deselectCheck(ID)

Arguments

ID

String or cell array that specifies the IDs of the checks to be deselected

success

True (1) if the check is deselected.

Description

This method deselects the checks specified by ID.

See Also

getCheckAll, deselectCheckForGroup, selectCheck

deselectCheckAll

Purpose

Deselect all checks.

Syntax

success = deselectCheckAll

Arguments

success

True (1) if all checks are deselected.

Description

Deselects all checks that are not disabled.

See Also

selectCheckAll

deselectCheckForGroup

Purpose

Deselect a group of checks.

Syntax

success = deselectCheckForGroup(groupName)

Arguments

groupName

String or cell array that specifies the names of the groups to be deselected

success

True (1) if the method succeeds in deselecting the specified group.

Description

Deselects a specified group of checks.

See Also

selectCheckForGroup

deselectCheckForTask

Purpose

Deselect checks that belong to a specified task or set of tasks.

Syntax

success = deselectCheckForTask(ID)

Arguments

ID

String or cell array of strings that specify the IDs of tasks whose checks are to be deselected.

success

True (1) if the specified tasks are deselected.

Description

Deselects checks belonging to the tasks specified by the ID argument.

See Also

getTaskAll, selectCheckForTask

deselectTask

Purpose

Deselect a task.

Syntax

success = deselectTask(ID)

Arguments

ID

String or cell array that specifies the ID of tasks to be deselected

success

True (1) if the method succeeded in deselecting the specified tasks

Description

Deselects the tasks specified by ID.

See Also

selectTask, getTaskAll

deselectTaskAll

Purpose

Deselect all tasks.

Syntax

success = deselectTaskAll

Arguments

success

True (1) if this method succeeds in deselecting all tasks

Description

Deselects all tasks.

See Also

selectTaskAll

displayReport

Purpose

Display report in Model Advisor.

Syntax

displayReport

Description

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.

See Also

Simulink.ModelAdvisor.reportexists

exportReport

Purpose

Create a copy of a report generated by Model Advisor.

Syntax

[success message] = exportReport(destination)

Arguments

destination

Path name of copy to be made of the report file.

success

True (1) if this method succeeded in creating a copy of the report at the specified location.

message

empty if the copy was successful; otherwise, the reason the copy did not succeed.

Description

This method creates a copy of the last report generated by the Model Advisor and stores the copy at the specified location.

See Also

Simulink.ModelAdvisor.reportexists

getBaselineMode

Purpose

Determine whether the Model Advisor is in baseline data generation mode.

Syntax

mode = getBaselineMode

Arguments

mode

Boolean value indicating baseline mode

Description

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.

See Also

setBaselineMode, verifyHTML, verifyCheckResult, verifyCheckResultStatus

getCheckAll

Purpose

Get the IDs of all checks.

Syntax

IDs = getCheckAll

Arguments

IDs

Cell array of strings specifying the IDs of all checks performed by the Model Advisor

Description

Returns a cell array of strings specifying the IDs of all checks performed by the Model Advisor.

See Also

getTaskAll, getGroupAll

getCheckForGroup

Purpose

Get checks that belong to a check group.

Syntax

IDs = getCheckForTask(groupName)

Arguments

groupName

String specifying the name of a group

IDs

Cell array of IDs

Description

Returns a cell array of IDs of the tasks belonging to the group specified by groupName.

See Also

getCheckForTask

getCheckForTask

Purpose

Get the checks that belong to a task.

Syntax

checkIDs = getCheckForTask(taskID)

Arguments

taskID

ID of a task

checkIDs

Cell array of IDs of checks belonging to the specified task

Description

Returns a cell array of IDs of the checks belonging to the task specified by taskID.

See Also

getCheckForGroup

getCheckResult

Purpose

Get the results of running a check or set of checks.

Syntax

result = getCheckResult(ID)

Arguments

ID

ID of a check or cell array of check IDs

result

A check result or cell array of check results

Description

Gets results for the specified checks. The format of the results depends on the checks that generated the data.

See Also

getCheckResultData, getCheckResultStatus

getCheckResultData

Purpose

Get the data resulting from running a check or set of checks.

Syntax

result = getCheckResultData(ID)

Arguments

ID

Check ID or cell array of check IDs

result

Data from a check result or cell array of data from check results

Description

Gets the check result data for the specified checks. The format of the data depends on the checks that generated the data.

See Also

getCheckResult, getCheckResultStatus

getCheckResultStatus

Purpose

Get the pass/fail status of a check or set of checks.

Syntax

result = getCheckResultStatus(ID)

Arguments

ID

Check ID or cell array of check IDs

result

Boolean or a cell array of Boolean values indication the pass/fail status of a check or set of checks

Description

Invoke this method after running a set of checks to determine whether the checks passed or failed.

See Also

getCheckResult, getCheckResultData

getGroupAll

Purpose

Get all groups of checks performed by the Model Advisor.

Syntax

IDs = getGroupAll

Arguments

IDs

Cell array of IDs of all groups of checks performed by the Model Advisor.

Description

Returns a cell array of IDs of all groups of checks performed by the Model Advisor.

See Also

getCheckAll, getTaskAll

getInputParameters

Purpose

Get input parameters of a check.

Syntax

params = obj.getInputParameters(check_ID)

Arguments

params

A cell array of ModelAdvisor.InputParameter objects.

obj

A variable representing the Simulink.ModelAdvisor object.

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.

Description

Returns the input parameters associated with a check.

See Also

ModelAdvisor.InputParameter

getListViewParameters

Purpose

Get list view parameters of a check.

Syntax

params = obj.getListViewParameters(check_ID)

Arguments

params

A cell array of ModelAdvisor.ListViewParameter objects.

obj

A variable representing the Simulink.ModelAdvisor object.

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.

Description

Returns the list view parameters associated with a check.

See Also

setListViewParameters, ModelAdvisor.ListViewParameter

getModelAdvisor

Purpose

Get a Model Advisor object for a system or subsystem.

Syntax

obj = Simulink.ModelAdvisor.getModelAdvisor(system)
obj = Simulink.ModelAdvisor.getModelAdvisor(system, 'new')

Arguments

system

Name of model for which the Model Advisor is to be gotten

'new'

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.

obj

Model Advisor object

Description

This static method (see Static Methods) creates and returns an instance of Simulink.ModelAdvisor class for the model or subsystem specified by system.

getSelectedCheck

Purpose

Get the currently selected checks.

Syntax

IDs = getSelectedCheck

Arguments

IDs

Cell array of IDs of currently selected checks

Description

Returns the checks currently selected in the Model Advisor.

See Also

getSelectedTask

getSelectedSystem

Purpose

Get system currently targeted by the Model Advisor.

Syntax

path = getSelectedSystem

Arguments

path

Path of the system selected system

Description

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.

See Also

getModelAdvisor

getSelectedTask

Purpose

Get selected tasks.

Syntax

IDs = getSelectedTask

Arguments

IDs

Cell array of IDs of currently selected tasks.

Description

Returns the tasks currently selected in the Model Advisor.

See Also

getSelectedCheck

getTaskAll

Purpose

Get the tasks performed by the Model Advisor.

Syntax

IDs = getTaskAll

Arguments

IDs

Cell array of IDs of tasks performed by the Model Advisor.

Description

Returns a cell array of IDs of tasks performed by the Model Advisor.

See Also

getCheckAll, getGroupAll

Simulink.ModelAdvisor.openConfigUI

Purpose

Starts the Model Advisor Configuration editor.

Syntax

Simulink.ModelAdvisor.openConfigUI

Description

This static method starts the Model Advisor Configuration editor. Use the Model Advisor Configuration editor to create customized configurations for the Model Advisor.

Simulink.ModelAdvisor.reportexists

Purpose

Determine whether a report exists for a model or subsystem.

Syntax

exists = reportexists('system')

Arguments

'system'

String specifying path name of a system or subsystem

exists

True (1) if a report exists for system

Description

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.

See Also

exportReport

runCheck

Purpose

Run the currently selected checks.

Syntax

success = runCheck

Arguments

success

True (1) if the checks were run.

Description

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.

See Also

selectCheck

runTask

Purpose

Run the currently selected tasks.

Syntax

success = runTask

Arguments

success

True (1) if the tasks were run.

Description

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.

See Also

selectTask

selectCheck

Purpose

Select a check.

Syntax

success = selectCheck(ID)

Arguments

ID

ID or cell array of IDs of checks to be selected

success

True (1) if this method succeeded in selecting the specified checks

Description

This method cannot select a check that is disabled.

See Also

selectCheckAll, selectCheckForGroup, deselectCheck

selectCheckAll

Purpose

Select all checks.

Syntax

success = selectCheckAll

Arguments

success

True (1) if this method succeeded in selecting all checks.

Description

Selects all checks that are not disabled.

See Also

selectCheck, selectCheckForGroup, deselectCheck

selectCheckForGroup

Purpose

Select a group of checks.

Syntax

success = selectCheckForGroup(ID)

Arguments

ID

ID or cell array of group IDs

success

True (1) if this method succeeded in selecting the specified groups

Description

Selects the groups specified by ID.

See Also

deselectCheckForGroup

selectCheckForTask

Purpose

Select checks that belong to a specified task or set of tasks.

Syntax

success = selectCheckForTask(ID)

Arguments

ID

ID or cell array of IDs of tasks whose checks are to be selected

success

True (1) if this method succeeded in selecting the checks for the specified tasks

Description

Selects checks belonging to the tasks specified by the ID argument.

See Also

deselectCheckForTask

selectTask

Purpose

Select a task.

Syntax

success = selectTask(ID)

Arguments

ID

ID or cell array of IDs of the task to be selected

success

True (1) if this method succeeds in selecting the specified tasks

Description

Selects a task.

See Also

deselectTask

selectTaskAll

Purpose

Select all tasks.

Syntax

success = selectTaskAll

Arguments

success

True (1) if this method succeeds in selecting all tasks

Description

Selects all tasks.

See Also

deselectTaskAll

setActionenable

Purpose

Set enable/disable status for check action

Syntax

obj.setActionenable(value)

Arguments

obj

A variable representing the Simulink.ModelAdvisor object.

value

Boolean value indicating whether the Action box is enabled or disabled.

  • true — enable the Action box.

  • false — Disable the Action box.

Description

The setActionenable method specifies the enables or disables the Action box. Only a check callback function can invoke this method.

See Also

ModelAdvisor.Action

setBaselineMode

Purpose

Set the baseline data generation mode for the Model Advisor.

Syntax

setBaselineMode(mode)

Arguments

mode

Boolean value indicating setting of Model Advisor's baseline mode, either on (true) or off (false)

Description

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.

See Also

getBaselineMode, verifyCheckResult, verifyHTML

setCheckerrorSeverity

Purpose

Set severity of a check failure.

Syntax

obj.setCheckerrorSeverity(value)

Arguments

obj

A variable representing the Simulink.ModelAdvisor object.

value

Integer indicating severity of failure.

  • 0 — Check Result = Warning

  • 1 — Check Result = Failed

Description

Sets result status for a currently running check that fails to value. Only a check callback function can invoke this method.

See Also

setCheckResultStatus

setCheckResult

Purpose

Set the result for the currently running check.

Syntax

success = setCheckResult(result)

Arguments

result

String or cell array that specifies the result of the currently running task

success

True (1) if this method succeeds in setting the check result

Description

Sets the check result for the currently running check. Only the check's callback function can invoke this method.

See Also

getCheckResult, setCheckResultData, setCheckResultStatus

setCheckResultData

Purpose

Set the result data for the currently running check.

Syntax

success = setCheckResultData(data)

Arguments

data

Result data to be set

success

True (1) if this method succeeds in setting the result data for the current check

Description

Sets the check result data for the currently running check. Only the check's callback function can invoke this method.

See Also

getCheckResultData, setCheckResult, setCheckResultStatus

setCheckResultStatus

Purpose

Set the pass/fail status for the currently running check.

Syntax

success = setCheckResultStatus(status)

Arguments

status

Boolean value that indicates the status of the check that just ran, either pass (true) or fail (false)

success

True (1) if the status was set.

Description

Sets the pass/fail status for the currently running check to status. Only the check's callback function can invoke this method.

See Also

getCheckResultStatus, setCheckResult, setCheckResultData, setCheckerrorSeverity

setListViewParameters

Purpose

Specify list view parameters for a check.

Syntax

obj.setListViewParameters(check_ID, params)

Arguments

obj

A variable representing the Simulink.ModelAdvisor object.

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.

params

A cell array of ModelAdvisor.ListViewParameter objects.

Description

Set the list view parameters for the check.

See Also

getListViewParameters, ModelAdvisor.ListViewParameter

verifyCheckRan

Purpose

Verify that the Model Advisor has run a set of checks.

Syntax

[success, missingChecks, additionalChecks] = verifyCheckRan(IDs)

Arguments

IDs

Cell array of IDs of checks to verify

success

Boolean value specifying whether the checks ran

missingChecks

Cell array of IDs for specified checks that ran

additionalChecks

Cell array of IDs for unspecified checks that ran

Description

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.

See Also

verifyCheckResultStatus

verifyCheckResult

Purpose

Generate a baseline Model Advisor check results file or compare the current check results to the baseline check results.

Syntax

[success message] = verifyCheckResult(baseline, checkIDs)

Arguments

baseline

Pathname of the baseline check results MAT-file

checkIDs

Cell array of check IDs.

success

Boolean value specifying whether the method succeeded

message

String specifying an error message

Description

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.

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.

See Also

setBaselineMode, getBaselineMode, runCheck, verifyCheckResultStatus

verifyCheckResultStatus

Purpose

Verify that a model has passed or failed a set of checks.

Syntax

[success message] = verifyCheckResultStatus(baseline, checkIDs)

Arguments

baseline

Array of Boolean variables

checkIDs

Cell array of check IDs.

success

Boolean value specifying whether the method succeeded

message

String specifying an error message

Description

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.

See Also

runCheck

verifyHTML

Purpose

Generate a baseline Model Advisor report or compare the current report to a baseline report.

Syntax

[success message] = verifyHTML(baseline)

Arguments

baseline

Pathname of a Model Advisor report

success

Boolean value specifying whether the method succeeded

message

String specifying an error message

Description

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.

See Also

setBaselineMode, getBaselineMode, verifyCheckResult

  


Related Products & Applications

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