Manage a Configuration Reference

Create and Attach a Configuration Reference

To use a configuration reference, it must point to freestanding configuration set. Create a freestanding configuration set before creating a configuration reference, see Create a Configuration Set in the Base Workspace.

To create a configuration reference:

  1. In the Model Explorer, in the Model Hierarchy pane, select the model.

  2. Click the Add Reference tool or select Add > Configuration Reference. The Create Configuration Reference dialog box opens.

  3. Specify the Configuration set name of the configuration set object in the base workspace to be referenced.

  4. Click OK. If you chose to create a configuration reference without first creating a configuration set object, a dialog box opens asking if you would like to continue. If you choose:

  5. A new configuration reference appears in the Model Hierarchy under the selected model. The default name of the new reference is Reference.

Resolve a Configuration Reference

An unresolved configuration reference is a configuration reference that is not pointing to a valid configuration set object.

To resolve a configuration reference:

  1. In the Model Hierarchy pane, select the unresolved configuration reference or right-click the configuration reference, and select Open from the context menu.

    The Configuration Reference dialog box opens in the Dialog pane or a separate window.

  2. Specify the Referenced configuration set to be a configuration set object already in the base workspace. If one does not exist, see Create a Configuration Set in the Base Workspace.

      Tip   Do not specify the name of a configuration reference. If you nest a configuration reference, an error occurs.

  3. Click OK or Apply.

    If you specified a Referenced configuration that exists in the base workspace, the Is Resolved field in the dialog box changes to yes.

Activate a Configuration Reference

After you create a configuration reference and attach it to a model, you can activate it so that it is the active configuration.

  • In the GUI, from the context menu of the configuration reference, select Activate.

  • From the API, execute setActiveConfigSet, specifying the configuration reference as the second argument.

When a configuration reference is active, the Is Active field of the Configuration Reference dialog box changes to yes. Also, the Model Explorer shows the name of the reference with the suffix (Active).

The freestanding configuration set of the active reference now provides the configuration parameters for the model.

Manage Configuration Reference Across Referenced Models

In a model hierarchy, you can share a configuration reference across referenced models. Using the Configuration Reference Propagation dialog box, you can propagate a configuration reference of a top model to an individual referenced model or to all referenced models in the model hierarchy. The dialog box provides:

  • A list of referenced models in the top model.

  • The ability to select only specific referenced models for propagation.

  • After propagation, the status for the converted configuration for each referenced model.

  • A view of the changed parameters after the propagation.

  • The ability to undo the configuration reference and restore the previous configuration settings for a referenced model.

To open the dialog box, in the Model Explorer, in the model hierarchy pane, right-click the configuration reference node of a model. In the context menu, select Propagate to Referenced Models. For an example, see Share a Configuration Across Referenced Models.

Change Parameter Values in a Referenced Configuration Set

To obtain a referenced configuration set:

  1. In the Model Hierarchy pane, select the configuration reference, or right-click the configuration reference, and select Open from the context menu.

    The Configuration Reference dialog box appears in the Dialog pane or in a separate window.

  2. To the right of the Referenced configuration field, click Open. The Configuration Parameters dialog box opens. You can now change and apply parameter values as you would for any configuration set.

Save a Referenced Configuration Set

If your model uses a configuration reference to specify the model configuration, before closing your model, you need to save the referenced configuration set to a MAT-file or MATLAB® script.

  1. In the Model Explorer, in the Model Hierarchy, select Base Workspace.

  2. In the Contents pane, right-click the name of the referenced configuration set object.

  3. From the context menu, select Export Selected.

  4. Specify the filename for saving the configuration set as either a MAT-file or a MATLAB script.

    Tip   When you reopen the model you must load the saved configuration set, otherwise, the configuration reference is unresolved. To set up your model to automatically load the configuration set object, see Callbacks for Customized Model Behavior.

Load a Saved Referenced Configuration Set

If your model uses a configuration reference to specify the model configuration, you need to load the referenced configuration set from a MAT-file or MATLAB script to the base workspace.

  1. In the Model Explorer, in the Model Hierarchy, right-click Base Workspace.

  2. From the context menu, select Import.

  3. Specify the filename for the saved configuration set and select OK. The configuration set object appears in the base workspace.

    Tip   When you reopen the model you must load the saved configuration set, otherwise, the configuration reference is unresolved. To set up your model to automatically load the configuration set object, see Callbacks for Customized Model Behavior.

Why is the Build Button Not Available for a Configuration Reference?

The Code Generation pane of the Configuration Parameters dialog box contains a Build button. Its availability depends on whether the configuration set displayed by the dialog box resides in a model or is a freestanding configuration set.

  • When the pane displays a configuration set stored in a model, the Build button is available. Click it to generate and compile code for the model.

  • When the pane displays a freestanding configuration set, the Build button is unavailable. The configuration set does not know which (if any) models link to it.

To provide the same capabilities whether a configuration set resides in a model or is freestanding, the Configuration Reference dialog box contains a Build button. This button has the same capability as its equivalent in the Configuration Parameters dialog box. It operates on the model that contains the configuration reference.

Was this topic helpful?