Manage a Configuration Reference

Create and Attach a Configuration Reference

To be used, a configuration reference must point to freestanding configuration set. To 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. Select Add > Configuration Reference or click the Add Configuration Reference tool .

  3. In the right panel, specify the Name of the configuration set object in the base workspace to be referenced.

  4. If you chose to create a configuration reference without first creating a configuration set object, a warning indicates that your configuration reference cannot be found. In this case, an unresolved configuration reference is created. For more information, see Unresolved Configuration References. Follow the instructions in Resolve a Configuration Reference.

  5. A new configuration reference appears in the Contents pane of the Configurations node for 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 Configurations node. In the Contents pane, select the unresolved configuration reference.

    The Configuration Reference dialog box opens in the Dialog pane.

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

    Tip

    You can specify the name of a configuration reference. But, nesting of a configuration reference beyond this depth results in an error.

  3. Click OK or Apply. The warning icon disappears.

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.

  • From the context menu of the configuration reference, select Activate.

  • From the command line, 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, select the Configurations node. In the Contents pane, right-click the configuration reference 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

From the Configuration Reference dialog box, you can open the referenced configuration set to change parameter values. Making changes to the standalone configuration set affects configuration references that refer to it, except for parameters that are overridden in those references. To obtain a referenced configuration set:

  1. To open the Configuration Reference dialog box, on the Modeling tab, click the Model Configuration Parameters button . The Configuration Reference dialog box displays a read-only view of the referenced configuration. In the dialog box you can browse, search, and get context-sensitive help for the parameters in the same way you do in the Configuration Parameters dialog box.

  2. At the top of the Configuration Reference dialog box, click the Model Configuration Parameters icon. The Configuration Parameters dialog box opens. You can now change and apply parameter values as you would for any configuration set.

  3. Your applied changes appear in the Configuration Reference dialog box.

Change Parameter Value in a Configuration Reference

When one reference to a standalone configuration requires a different value for a parameter, you can override that parameter in the configuration reference. Override a parameter to change its value in the reference without changing the standalone configuration. For an overridden parameter, the reference uses the value you assign locally instead of the value in the referenced configuration set. For example, the models of a hierarchy may reference a standalone configuration in which the parameter Model Referencing > Total number of instances allowed per top model is set to Multiple. If you want to reference a model only once in the hierarchy, you can override the parameter for the configuration reference of only that model and set the value to One. Simulink® detects a violation if the hierarchy references that model more than one time.

  1. To open the Configuration Reference dialog box, on the Modeling tab, click the Model Configuration Parameters button .

  2. Right-click the parameter you want to change and select Override from the context menu. You can now change the parameter value as you would for any configuration set. In the left pane, each component displays the number of overridden parameters it contains.

  3. Click Apply to keep the changes or Cancel to restore the parameter to the referenced value. Changes you make to a parameter value apply only to the configuration reference in which you override and edit the parameter. They do not affect other references to the referenced configuration set.

  4. To restore an overridden parameter to its value from the referenced configuration set, right-click the overridden parameter and select Restore from the context menu. The overridden parameter resets to the value in the referenced configuration and becomes read-only again.

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.

Related Examples

More About