Main Content

attachConfigSetCopy

Copy configuration set or configuration reference and associate it with model

Description

example

configObjCopy = attachConfigSet(model, configObj) creates a copy of the configuration set or configuration reference configObj and associates it with model. The function returns the copy of the configuration as a Simulink.ConfigSet object or a Simulink.ConfigSetRef object.

example

attachConfigSetCopy(model, configObj, allowRename) associates the configuration copy with the model and determines how Simulink® handles a name conflict between the configuration 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 the copy of configObj before associating it with the model.

Examples

collapse all

Create a copy of the active configuration for the model vdp and attach the copy to the model fuelsys.

Open the model vdp and get the active configuration object. Name the configuration vdpConfig.

vdp
vdpConfigObj = getActiveConfigSet('vdp');
set_param(vdpConfigObj,'Name','vdpConfig');

Each model has a configuration with the default name Configuration. To avoid a naming conflict when you attach the configuration copy to fuelsys, name the configuration vdpConfig.

set_param(vdpConfigObj,'Name','vdpConfig');

Open the model fuelsys. Copy the configuration object vdpConfigObj and attach it to fuelsys.

fuelsys
attachConfigSetCopy('fuelsys',vdpConfigObj);

To use the configuration in fuelsys, activate it.

Create a copy of the active configuration for the model vdp and attach the copy to fuelsys. Use the allowRename argument to avoid naming conflicts.

Open the model vdp and get the active configuration object. The configuration has the default name Configuration.

vdp
vdpConfigObj = getActiveConfigSet('vdp');

Open the model fuelsys. Copy the configuration object vdpConfigObj and attach it to fuelsys. Specify allowRename as true.

fuelsys
attachConfigSetCopy('fuelsys',vdpConfigObj,true);

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

To use the configuration in fuelsys, 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 copy, specified as a Simulink.ConfigSet object or a Simulink.ConfigSetRef object.

Example: myConfigObj

Specification that determines if Simulink renames the configuration object copy in the case of a name conflict, specified as a Boolean. If allowRename is false and a name conflict occurs, Simulink generates an error.

Example: true

Introduced in R2006b