Documentation Center

  • Trials
  • Product Updates

Simulink.ConfigSet

Access model configuration set

Description

Instances of this handle class allow you to write programs to create, modify, and attach configuration sets to models. See Manage a Configuration Set and Overview for more information.

Property Summary

Name

Description

Components

Components of the configuration set.

Description

Description of the configuration set.

Name

Name of the configuration set.

    Note:   You can use the Model Configuration dialog box to set the Name and Description properties of a configuration set. See Model Configuration Pane for more information.

Method Summary

Name

Description

attachComponent

Attach a component to a configuration set.

copy

Create a copy of a configuration set.

getComponent

Get a component of a configuration set.

getFullName

Get the full path of a configuration set.

getModel

Get the handle of the model that owns a configuration set.

get_param

Get the value of a configuration set parameter.

isActive

Determine whether a configuration set is the active set of the model that owns it.

isValidParam

Determine whether a specified parameter is a valid parameter of a configuration set.

saveAs

Save a configuration set to a MATLAB® file.

setPropEnabled

Prevent or allow a user to change a parameter.

set_param

Set the value of a configuration set parameter.

Properties

Components

Description

Array of Simulink.ConfigComponent objects representing the components of the configuration set. For example, solver parameters and data import/export parameters.

Data Type

array

Access

RW

Description

Description

Description of the configuration set. You can use this property to provide additional information about a configuration set, such as its purpose. This field can remain blank.

Data Type

string

Access

RW

Name

Description

Name of the configuration set. This name represents the configuration set in the Model explorer.

Data Type

string

Access

RW

Methods

attachComponent

Purpose

Attach a component to this configuration set.

Syntax

attachComponent(component)

Arguments

component

Instance of Simulink.ConfigComponent class.

Description

This method replaces a component in this configuration set with a component having the same name.

example

The following example replaces the solver component of the active configuration set of model A with the solver component of the active configuration set of model B.

hCs = getActiveConfigSet('B');
hSolverConfig = hCs.getComponent('Solver');
hSolverConfig = hSolverConfig.copy;
hCs = getActiveConfigSet('A');
hCs.attachComponent(hSolverConfig);

copy

Purpose

Create a copy of this configuration set.

Syntax

copy

Description

This method creates a copy of this configuration set.

    Note   You must use this method to create copies of configuration sets because Simulink.ConfigSet is a handle class. See Handle Versus Value Classes for more information.

getComponent

Purpose

Get a component of this configuration set.

Syntax

getComponent(componentName)

Arguments

componentName

String specifying the name of the component to be returned.

Description

Returns the specified component. Omit the argument to get a list of the names of the components that this configuration set contains.

Example

The following code gets the solver component of the active configuration set of the currently selected model.

hCs = getActiveConfigSet(gcs);
hSolverConfig = hCs.getComponent('Solver');

The following code displays the names of the components of the currently selected active configuration set of the model at the MATLAB command line.

hCs = getActiveConfigSet(gcs);
hCs.getComponent

getFullName

Purpose

Get the full path of a configuration set.

Syntax

getFullName

Description

This method returns a string specifying the full path of a configuration set, for example, 'vdp/Configuration'.

getModel

Purpose

Get the model that owns this configuration set.

Syntax

getModel

Description

Returns a handle to the model that owns this configuration set.

Example

The following command opens the block diagram of the model that owns the configuration set referenced by the MATLAB workspace variable hCs.

open_system(hCs.getModel);

get_param

Purpose

Get the value of a configuration set parameter.

Syntax

get_param(paramName)

Arguments

paramName

String specifying the name of the parameter whose value is to be returned.

Description

This method returns the value of the specified parameter. Specifying paramName as 'ObjectParameters' returns the names of the valid parameters in the configuration set.

Example

The following command gets the name of the solver used by the selected active configuration of the model.

hAcs = getActiveConfigSet(bdroot);
hAcs.get_param('SolverName');

    Note   You can also use the get_param model construction command to get the values of parameters of an active configuration set of a model. For example, get_param(bdroot, 'SolverName') gets the solver name of the currently selected model.

isActive

Purpose

Determine whether configuration set is the active configuration set for the model.

Syntax

isActive

Description

Returns true if this configuration set is the active configuration set of the model that owns this configuration set.

isValidParam

Purpose

Determine whether a specified parameter is a valid parameter of this configuration set. A parameter is valid if it is compatible with other parameters in the configuration set. For example, if SolverType is 'variable-step', FixedStep is an invalid parameter.

Syntax

isValidParam(paramName)

Arguments

paramName

String specifying the name of the parameter whose validity is to be determined.

Description

This method returns true if the specified parameter is a valid parameter of this configuration set; otherwise, it returns false.

Example

The following code sets the parameter StopTime only if it is a valid parameter of the currently selected active configuration set.

hAcs = getActiveConfigSet(gcs);
if hAcs.isValidParam('StopTime')
	set_param('StopTime', '20');
end

saveAs

Purpose

Save configuration set to MATLAB file

Syntax

saveAs(fileName)
saveAs(fileName, 'paramName', paramValue)

Arguments

fileName

String specifying the name of the MATLAB file that the method creates.

paramName, paramValue

Parameter name and value pairs that you optionally use to format the MATLAB file.

NameValue
'-format'
  • 'MATLAB function' (default) — Creates a MATLAB function.

  • 'MATLAB script' — Creates a MATLAB script.

'-comments'
  • 'on' (default) — The MATLAB file:

    • Includes the GUI name of the parameter as a comment to help identify the parameters.

    • Groups the parameters by the pane in the Configuration Parameters dialog box on which they are displayed.

  • 'off' — Does not include comments in the MATLAB file, so that the file generates faster.

'-varname'

'variable' — Any valid variable name. If you do not specify this parameter, the MATLAB script uses cs for the variable.

When you specify '-format', 'MATLAB script', use '-varname', 'variable' to specify the variable that the script uses for the configuration set object. When you run the script, the script creates the variable in the base workspace.

Description

saveAs(fileName) saves a configuration set to a MATLAB file. Before saving, you must get a handle to the configuration set. Use fileName to specify the file name.

saveAs(fileName, 'paramName', paramValue) accepts one or more comma-separated parameter name and value pairs. For the valid parameter name and value pairs, see the previous arguments section.

Example

The following code gets the configuration set for sldemo_counters and creates a function called ConfiguredDataFunction.

% Get the active configuration set from sldemo_counters.
hCs = getActiveConfigSet('sldemo_counters');
% Save the configuration set as a function.
hCs.saveAs('ConfiguredDataFunction');

The following code gets the configuration set for sldemo_counters and creates a script called ConfiguredDataScript. The script uses config_set for the variable name.

% Get the active configuration set from sldemo_counters.
hCs = getActiveConfigSet('sldemo_counters');
% Save the configuration set as a script.
hCs.saveAs('ConfiguredDataScript', '-format', 'MATLAB script', '-varname', 'config_set');

See Also

getActiveConfigSet, getConfigSet

setPropEnabled

Purpose

Enable a configuration set parameter to be changed.

Syntax

setPropEnabled(paramName, isenabled)

Arguments

paramName

Name of the parameter whose value is to be set.

isenabled

Specify as true to enable parameter; as false, to disable the parameter.

Description

This method sets the enabled status the parameter specified by paramName to the value specified by isenabled. Disabling a parameter prevents the user from changing it.

Example

The following code prevents the user from setting the simulation stop time of the currently selected model.

hAcs = getActiveConfigSet(gcs);
hAcs.setPropEnabled('StopTime', false);

set_param

Purpose

Set the value of a configuration set parameter.

Syntax

set_param(paramName, paramValue)

Arguments

paramName

Name of the parameter whose value is to be set.

paramValue

Value to assign to the parameter.

Description

This method sets the configuration set parameter specified by paramName to the value specified by paramValue.

Example

The following command sets the simulation stop time of the selected active configuration set.

hAcs = getActiveConfigSet(gcs);
hAcs.set_param('StopTime', '20');

    Note   You can also use the set_param model construction command to set the parameters of the active configuration set. For example, set_param(gcs, 'StopTime', '20') sets the simulation stop time of the currently selected model.

Was this topic helpful?