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 the model.

For example, to create a custom configuration and associate the configuration with a model newModel, follow these steps.

  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. To create a custom configuration, you can use either of these approaches:

    For this example, use the Model Advisor Configuration Editor to create a custom configuration.

  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 configuration file that you loaded contains checks that are incompatible with the newer version of MATLAB you use, you get a dialog box asking whether to automatically fix issues in the configuration. To fix the issues automatically, click Yes, and then perform the steps as described in Update or Delete Checks in Configuration Files Automatically Using Model Advisor.

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

  9. 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");

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

     ModelAdvisor.getModelConfiguration("newModel")

  10. 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 Model Advisor Configuration Editor to Customize 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 Model Advisor Configuration Editor to Customize Model Advisor.

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