Documentation

Advisor.Application class

Package: Advisor
Superclasses:

Run Model Advisor across model hierarchy

Description

Use instances of Advisor.Application to run Model Advisor checks across a model hierarchy. You can use Advisor.Application to:

  • Run checks on referenced models.

  • Select model components for Model Advisor analysis.

  • Select checks to run during Model Advisor analysis.

Consider using Advisor.Application if you have a large model with subsystems and model references. Advisor.Application does not run checks on library models. If you want to run checks on multiple independent models that are not in a model reference hierarchy or you want to leverage parallel processing, use ModelAdvisor.run to run Model Advisor checks on your model.

The Advisor.Application methods use the following definitions:

  • Model component — Model in the system hierarchy. Models that the root model references and that setAnalysisroot specifies are model components.

  • Check instance — Instantiation of a ModelAdvisor.Check object in the Model Advisor configuration. Each check instance has an instance ID. When you change the Model Advisor configuration, the instance ID can change.

Construction

To create an Advisor.Application object, use Advisor.Manager.createApplication.

Properties

expand all

Name of root model in the model hierarchy to analyze, as specified by the Advisor.Application.setAnalysisRoot method. This property is read only.

Unique identifier for the Advisor.Application object. This property is read only.

Run analysis in a temporary working folder. Specified by the Advisor.Manager.createApplication method. This property is read only.

Data Types: logical

Methods

deleteDelete Advisor.Application object
deselectCheckInstancesClear check instances from Model Advisor analysis
deselectComponentsClear model components from Model Advisor analysis
generateReportGenerate report for Model Advisor analysis
getCheckInstanceIDsObtain check instance IDs
getResultsAccess Model Advisor analysis results
loadConfigurationLoad Model Advisor configuration
runRun Model Advisor analysis on model components
selectCheckInstancesSelect check instances to use in Model Advisor analysis
selectComponentsSelect model components for Model Advisor analysis
setAnalysisRootSpecify model hierarchy for Model Advisor analysis

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

expand all

This example shows how to run a check on model sldemo_mdlref_counter referenced from sldemo_mdlref_basic.

  1. In the Command Window, open model sldemo_mdlref_basic and referenced model sldemo_mdlref_counter.

    open_system('sldemo_mdlref_basic');
    open_system('sldemo_mdlref_counter');
  2. Save a copy of the models to a work folder, renaming them to mdlref_basic and mdlref_counter.

    save_system('sldemo_mdlref_basic','mdlref_basic');
    save_system('sldemo_mdlref_counter','mdlref_counter');
  3. In mdlref_basic, change model reference from sldemo_mdlref_counter to mdlref_counter. Save mdlref_basic.

    set_param('mdlref_basic/CounterA','ModelName','mdlref_counter');
    set_param('mdlref_basic/CounterB','ModelName','mdlref_counter');
    set_param('mdlref_basic/CounterC','ModelName','mdlref_counter');
    save_system('mdlref_basic');
  4. Set root model to mdlref_basic.

    RootModel='mdlref_basic';
  5. Create an Application object.

    app = Advisor.Manager.createApplication();
  6. Set root analysis.

    setAnalysisRoot(app,'Root',RootModel);
  7. Clear all check instances from Model Advisor analysis.

    deselectCheckInstances(app);
    
  8. Select check Identify unconnected lines, input ports, and output ports using check instance ID.

    instanceID = getCheckInstanceIDs(app,'mathworks.design.UnconnectedLinesPorts');
    checkinstanceID = instanceID(1);
    selectCheckInstances(app,'IDs',checkinstanceID);
    
  9. Run Model Advisor analysis.

    run(app);
    
  10. Get analysis results.

    getResults(app);
    
  11. Generate and view the Model Advisor report. The Model Advisor runs the check on both mdlref_basic and mdlref_counter.

    report = generateReport(app);
    web(report)
  12. Close the models.

    close_system('mdlref_basic');
    close_system('mdlref_counter');

This example shows how to run a check on subsystem CounterA referenced from sldemo_mdlref_basic.

  1. In the Command Window, open model sldemo_mdlref_basic.

    open_system('sldemo_mdlref_basic');
    
  2. Set root model to sldemo_mdlref_basic.

    RootModel='sldemo_mdlref_basic';
  3. Create an Application object.

    app = Advisor.Manager.createApplication();
  4. Set root analysis to subsystem sldemo_mdlref_basic/CounterA.

    setAnalysisRoot(app,'Root','sldemo_mdlref_basic/CounterA','RootType','Subsystem');
  5. Clear all check instances from Model Advisor analysis.

    deselectCheckInstances(app);
    
  6. Select check Identify unconnected lines, input ports, and output ports using check instance ID.

    instanceID = getCheckInstanceIDs(app,'mathworks.design.UnconnectedLinesPorts');
    checkinstanceID = instanceID(1);
    selectCheckInstances(app,'IDs',checkinstanceID);
    
  7. Run Model Advisor analysis.

    run(app);
    
  8. Get analysis results.

    getResults(app);
    
  9. Generate and view the Model Advisor report. The Model Advisor runs the check on subsystem sldemo_mdlref_basic/CounterA.

    report = generateReport(app);
    web(report)
  10. Close the model.

    close_system('sldemo_mdlref_basic');
    

See Also

Topics

Introduced in R2015b

Was this topic helpful?