Main Content

addConfiguration

Add new variant configuration to variant configuration data object

    Description

    Note

    This function requires Variant Manager for Simulink®.

    addConfiguration(varconfigdata,varconfigname) adds a new variant configuration with the name varconfigname to a Simulink.VariantConfigurationData object varconfigdata.

    addConfiguration(___,description) adds a new variant configuration with the specified description to the variant configuration data object.

    addConfiguration(___,controlvars) adds a new variant configuration with the specified control variables to the variant configuration data object.

    example

    Examples

    collapse all

    1. Create an empty Simulink.VariantConfigurationData object.

    varconfigdata = Simulink.VariantConfigurationData
    varconfigdata = 
      VariantConfigurationData with properties:
    
                Configurations: [1×0 struct]
                   Constraints: [1×0 struct]
        PreferredConfiguration: ''
    
    

    2. Create a structure 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="PlantLocation",Value=PlantLoc,Source="topdata.sldd")
    ctrlVarStruct = struct with fields:
          Name: "PlantLocation"
         Value: [1×1 Simulink.VariantControl]
        Source: "topdata.sldd"
    
    

    3. Add the new configuration to varconfigdata.

    addConfiguration(varconfigdata,"InternalPlantConfig", ...
     "Internal Plant Controller",ctrlVarStruct);

    Input Arguments

    collapse all

    Variant configuration data to which you want to add a new configuration, specified as a Simulink.VariantConfigurationData object.

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

    Example: "LinInterExpNoNoise"

    Data Types: char | string

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

    Example: "Linear configuration with internal plant"

    Data Types: char | string

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

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

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

      • MATLAB® variable

      • Simulink.Parameter

      • AUTOSAR.Parameter

      • Simulink.VariantControl whose value is a MATLAB variable

      • Simulink.VariantControl whose value is a Simulink.Parameter

      • Simulink.VariantControl whose value is a user-defined type that inherits from Simulink.Parameter

      • Simulink.VariantControl whose value is a Simulink.Parameter object or an object of a class that inherits from Simulink.Parameter, with the value of the object set to a mathematical expression specified using the slexpr function.

    • Source — Data source of the control variable, specified as a character vector or string scalar.

    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

    Version History

    Introduced in R2013b