Main Content

addConfiguration

Class: Simulink.VariantConfigurationData
Package: Simulink

Add new variant configuration to VariantConfigurationData object

Description

Note

This method requires Variant Manager for Simulink®.

example

vcdataObj.addConfiguration(name) adds a new variant configuration with the given name to the variant configuration data object vcdataObj, which is an object of the Simulink.VariantConfigurationData class.

vcdataObj.addConfiguration(name,description) adds a new variant configuration with a given name and optional description to the variant configuration data object.

vcdataObj.addConfiguration(name,description,controlVars) adds a new variant configuration with a given name, optional description, and control variables to the variant configuration data object.

Input Arguments

expand all

Name of the new variant configuration that you want to add to the variant configuration data object, specified as a character vector or string.

Example: 'LinInterExpNoNoise'

Data Types: char | string

Description of the variant configuration, specified as a character vector or string.

Example: 'Linear configuration with internal plant'

Data Types: char | string

Variant control variable names and their values, specified as a structure or array of structures with fields:

  • Name — Name of the control variable, specified as a character vector

  • Value — Value of the control variable, specified as any of these data types:

    • Normal MATLAB® variable

    • Simulink.Parameter

    • Simulink.VariantControl with value as normal MATLAB variable

    • Simulink.VariantControl with value as Simulink.Parameter

  • Source — Source of the control variable, specified as a character vector. Source must be'base workspace' or the name of a data dictionary.

Example: ctrlVarStruct=struct(Name='Noise',Value='NoiseType.NoNoise',Source='plant.sldd');

For an example that shows the use of different types of variant control variables, see Use Variant Control Variables in Variant Blocks.

Data Types: struct

Examples

expand all

This example shows how to add a new variant configuration to a variant configuration data object.

Create an empty Simulink.VariantConfigurationData object.

vardataObj = Simulink.VariantConfigurationData
vardataObj = 
  VariantConfigurationData with properties:

            Configurations: [1×0 struct]
               Constraints: [1×0 struct]
    PreferredConfiguration: ''

Create a struct with the control variable names and values for the new configuration.

% Define a variant control variable
PlantLoc = Simulink.VariantControl('Value',1,'ActivationTime','code compile');
% Create a variant control variable structure
ctrlVarStruct = struct(Name='PlantLoc',Value=PlantLoc,Source='topdata.sldd')
ctrlVarStruct = struct with fields:
      Name: 'PlantLoc'
     Value: [1×1 Simulink.VariantControl]
    Source: 'topdata.sldd'

Add the new configuration to vardataObj.

vardataObj.addConfiguration('LinInterExpNoNoise','Linear Internal Experimental Plant Controller',ctrlVarStruct)

Version History

Introduced in R2013b