Main Content

attachConfigSet

Associate configuration set or configuration reference with model

Description

example

attachConfigSet(model, configObj) associates the configuration set or configuration reference configObj with model.

example

attachConfigSet(model, configObj, allowRename) associates the configuration set to the model and determines how Simulink® handles a name conflict between configObj and any configuration objects that are already attached to the model.

If allowRename is false and the configuration object specified by configObj has the same name as a configuration object already attached to model, Simulink generates an error. If allowRename is true and a name conflict occurs, Simulink provides a unique name for configObj before associating it with the model.

Examples

collapse all

Create a configuration set and attach it to a model.

Open the model sldemo_fuelsys.

sldemo_fuelsys

Create a configuration set named Config1 and attach it to the model.

configObj = Simulink.ConfigSet;
set_param(configObj,'Name','Config1')
attachConfigSet('sldemo_fuelsys',configObj)

To use the configuration set for the model, activate it.

Attach a configuration set to a model that already has a configuration set with the same name.

Open the model sldemo_fuelsys. The model uses a configuration set with the default name Configuration.

sldemo_fuelsys

Create another configuration set and name it Configuration.

configObj = Simulink.ConfigSet;
set_param(configObj,'Name','Configuration')

Attach the configuration to the model. Specify allowRename as true.

attachConfigSet('sldemo_fuelsys',configObj,true)

Because the model already has a configuration set named Configuration, Simulink changes the name of configObj to Configuration1 before attaching it to the model.

To use the configuration for the model, activate Configuration1.

Input Arguments

collapse all

Model to which you want to attach a configuration set, specified as a character vector or string scalar. The model must be open.

Example: 'my_model'

Configuration object that you want to attach to the model, specified as a ConfigSet object or a Simulink.ConfigSetRef object.

Example: myConfigObj

Specification that determines if Simulink renames the configuration object in the case of a name conflict, specified as a Boolean. If allowRename is false and a name conflict occurs, Simulink generates an error. You cannot attach a configuration object to a model if the configuration object is already attached to another model.

Example: true

Introduced before R2006a