| Simulink® | ![]() |
| On this page… |
|---|
Activating a Configuration Set Copying, Deleting, and Moving Configuration Sets Copying Configuration Set Components |
A configuration set is a named set of values for a model's parameters, such as solver type and simulation start or stop time. Every new model is created with a default configuration set, called Configuration, that initially specifies default values for the model's parameters. You can subsequently create and modify additional configuration sets and associate them with the model. The sets associated with a model can specify different values for any or all configuration parameters.
This section describes techniques for defining and using configuration sets that are stored in individual models. Such configuration sets are available only to the model that contains them. The next section, Referencing Configuration Sets, describes techniques for storing configuration sets in the base workspace, independently of any model. Such configuration sets can be shared by any number of models.
A configuration set comprises groups of related parameters called components. Every configuration set includes the following components:
Solver
Data Import/Export
Optimization
Diagnostics
Hardware Implementation
Model Referencing
Some Simulink-based products, such as Real-Time Workshop®, define additional components. If such a product is installed on your system, the configuration set also contains the components that it defines.
Only one of the configuration sets associated with a model is active at any given time. The active set determines the current values of the model's parameters. Changing the value of a parameter in the Model Explorer changes its value in the associated configuration set. You can change the active or inactive set at any time (except when executing the model). In this way, you can quickly reconfigure a model for different purposes, e.g., testing and production, or apply standard configuration settings to new models.
To display the configuration sets associated with a model, open the Model Explorer (see The Model Explorer). The configuration sets associated with the model appear as gear-shaped nodes in the Model Explorer's Model Hierarchy pane.

The Model Explorer's Contents pane displays the components of the selected configuration set. The Model Explorer's Dialog pane displays a dialog for setting the parameters of the selected group (see Configuration Parameters Dialog Box).
To activate a configuration set, right-click the configuration set's node to display the node's context menu, then select Activate from the context menu.
In Model Explorer, to open the configuration parameter dialog for a configuration set, right-click the configuration set's node to display the node's context menu, then select Open from the context menu. You can open the configuration parameter dialog for any configuration set, whether it is active or not. You might want to open a configuration set to inspect or edit the parameter settings.
The title bar of the dialog indicates if the configuration set is active or inactive.


Note Every configuration set has its own configuration parameter dialog. As you change the state of a configuration set, the top-left corner label changes to reflect the state. |
You can use edit commands on the Model Explorer's Edit or context menus or object drag-and-drop operations to delete, copy, and move configuration sets among models displayed in the Model Explorer's Model Hierarchy pane.
For example, to copy a configuration set, using edit commands:
Select the model with a configuration set that you want to copy in the Model Hierarchy pane.
Select the configuration set that you want to copy in the Contents pane.
Select Copy from the Model Explorer's Edit menu or the configuration set's context menu.
Select Paste from the Model Explorer's Edit menu or from the model's context menu.
To copy the configuration set, using object drag-and-drop, hold the right mouse button down and drag the configuration set's node to the node of the model in which you want to create the copy. To move a configuration set from one model to another, using drag-and-drop, hold the left mouse button down and drag the configuration set's node to the node of the destination model.
Note You cannot move or delete a model's active configuration set. |
To copy a configuration set component from one configuration set to another:
Select Copy from the Model Explorer's Edit menu or the component's context menu.
Select the configuration set into which you want to copy the component.
Select Paste from the Model Explorer's Edit menu or the component's context menu.
To create a new configuration set, select Configuration
Set from the Model Explorer's Add menu
or press the Add Configuration button
in the Model Explorer's
toolbar. You can also create a new configuration set by copying an
existing configuration set.
To set the value of a parameter in a configuration set, select the configuration set in the Model Explorer and then edit the value of the parameter on the corresponding dialog in the Model Explorer's dialog view.
An application program interface (API) is provided that permits you to create and manipulate configuration sets from the command line or in a MAT-file or M-file. The API includes the Simulink.ConfigSet data object class and the following model construction commands:
These commands, along with the methods and properties of Simulink.ConfigSet class, allow an M-file program to create and modify configuration sets, attach configuration sets to a model, set a model's active configuration set, open and close configuration sets, and detach configuration sets from a model. For example, to create a configuration set from scratch at the command line, enter
cfg_set = Simulink.ConfigSet
The default name of the new configuration set is Configuration. To change the name, execute
cfg_set.Name = 'name'
where name is the set's new name.
Use get_param and set_param to get and set the value of a parameter in a configuration set. For example, to specify the Simulink® fixed-step discrete solver in the configuration set, execute
set_param(cfg_set, 'Solver', 'FixedStepDiscrete')
To save the configuration set in a MAT-file, execute
save mat_file cfg_set
where mat_file is the name of the MAT-file. To load the configuration set, execute
load mat_file
To prevent or allow a user to change the value of a parameter in a configuration set using either the Model Explorer or set_param command, execute
setPropEnabled(cfg_set, 'param', [0 | 1])
where param is the name of the parameter. To attach a configuration set to a model, execute
attachConfigSet(model, cfg_set)
where model is the model name (in quotes) or object. To get a model's active configuration set, execute
cfg_set = getActiveConfigSet(model)
To get a configuration set's full name (e.g., 'engine/Configuration'), execute
getFullName(cfg_set)
To set a model's active set, execute
setActiveConfigSet(model, 'cfg_set_name')
where cfg_set_name is the configuration set's name.
To open the configuration parameter dialog for an active configuration set, execute
openDialog(cfg_set)
To open the configuration parameter dialog for any configuration set, execute
cfg_set= getConfigSet(gcs,'cfg_set_name') openDialog(cfg_set);
where cfg_set_name is the configuration set's name.
To close the configuration parameter dialog for a configuration set, execute
closeDialog(cfg_set);
To rename the active configuration set of modelA, copy it, and attach a copy of that configuration to modelB, execute
activeConfigA = getActiveConfigSet('modelA');
activeConfigA.Name = 'myactiveConfigA';
newConfig = attachConfigSetCopy('modelB', activeConfigA);where activeConfigA is the active configuration set of modelA. modelA is the model whose active configuration set you want to copy. modelB is the model with which you want to associate the copy of the configuration set. You can also use this command to make multiple copies of one configuration set. This might be useful if you want to programmatically assign copies of the same configuration set to multiple models.
To detach a configuration set from a model, execute
detachConfigSet(model, cfg_set)
where model is the model name (in quotes) or object.
The Model Configuration dialog appears in the Model Explorer dialog pane when you select any model configuration.

You can edit the name and description of your configuration. See Model Configuration Pane.
The Model Configuration Preferences dialog appears in the Model Explorer dialog pane when you view the default model configuration.
Enable View > Show Configuration Preferences in the Model Explorer menu.
Select Configuration Preferences under the Simulink Root node in the Model Explorer Model Hierarchy pane.
You can also edit the configuration defaults in the Simulink Preferences window. See Model Configuration Pane.
![]() | Importing and Exporting Simulation Data | Referencing Configuration Sets | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |