Main Content

Load and Associate a Custom Configuration with a Model

Custom configurations allow you to specify which checks run during Model Advisor analysis. When you load a custom configuration, the Model Advisor uses the folders and checks specified by the configuration. You can also associate a custom configuration with your model so that the Model Advisor uses that configuration each time you open that model.

For example, to create a custom configuration and associate the configuration with a model newModel:

  1. Set your current folder to a writeable directory.

  2. Create and save a new model called newModel. In the MATLAB® Command Window, enter:

    new_system("newModel");
    save_system("newModel");

  3. Open the Model Advisor by entering:

    modeladvisor("newModel")

  4. In the Model Advisor, click Open > Open Configuration Editor to open the Model Advisor Configuration Editor.

    You can use the Model Advisor Configuration Editor to specify the folders and checks that you want to include in the Model Advisor. For information on how to create a custom configuration, see Use the Model Advisor Configuration Editor to Customize the Model Advisor.

  5. In the Model Advisor Configuration Editor, click Save As to save a new, custom configuration file. For this example, save the configuration file as customConfig.json. The Model Advisor Configuration Editor prompts you to save the configuration as the default configuration. For this example, click No.

  6. Update your Simulink® environment to include the custom configuration file. At the MATLAB command line, enter:

    Advisor.Manager.refresh_customizations

    For more information, see Update the Environment to Include Your Custom Configuration.

  7. Re-open the Model Advisor for the model newModel. In the MATLAB Command Window, enter:

    modeladvisor("newModel")

  8. In the Model Advisor, click Open > Load Configuration and select the custom configuration file customConfig.json to load the configuration file into the Model Advisor.

    If the Model Advisor is unable to load a check listed in your configuration, the Model Advisor returns a warning in the MATLAB Command Window. To turn off these warnings, follow the steps listed in Suppress Warning Message for Missing Checks.

  9. In the Model Advisor Check Selector pane, you can verify that you see the folders and checks specified in the custom configuration. If you expect a folder or check to appear in the Model Advisor and it does not, see Use the Model Advisor Configuration Editor to Customize the Model Advisor and Update the Environment to Include Your Custom Configuration.

  10. If you want the Model Advisor to use this configuration each time you open the model newModel, associate the loaded configuration file with the model by using one of these approaches:

    • In the Model Advisor, click Open > Associate Configuration to Model. The Model Advisor opens the Configuration Parameters dialog box for the model. The Model Advisor configuration file parameter lists the configuration file associated with the model. Click OK.

    • In the MATLAB Command Window, provide the model name and configuration file name as inputs to the function ModelAdvisor.setModelConfiguration.

      ModelAdvisor.setModelConfiguration("newModel","customConfig.json");

    For Model Advisor configuration files created in R2021b or earlier, use R2022a or later to open and re-save the configuration file in the Model Advisor Configuration Editor before associating the file with a model.

  11. You can view the Model Advisor configuration file associated with the model by entering:

    ModelAdvisor.getModelConfiguration("newModel")
  12. To return to your default configuration, click Open > Restore Default Configuration.

    For information on how to restore the default shipping configuration or set a new default configuration, see Use the Model Advisor Configuration Editor to Customize the Model Advisor.

Note

The Model Advisor looks for configuration files in the following order:

  1. The configuration that you specify by using the configfile input argument of the modeladvisor function.

  2. The configuration associated with the model.

  3. The default configuration. The default configuration is either the default shipping configuration or the default configuration that you set. For more information on the default configuration, see Use the Model Advisor Configuration Editor to Customize the Model Advisor.

The Model Advisor loads the first configuration file that it finds and ignores other configuration files.