主要内容

addConfiguration

Add new variant configuration to variant configuration data object

    Description

    Add-On Required: This feature requires the Variant Manager for Simulink add-on.

    addConfiguration(varConfigData,ConfigurationName=varConfigName) adds a new variant configuration with the name varConfigName to a Simulink.VariantConfigurationData object varConfigData.

    addConfiguration(___,Name=Value) specifies options using one or more name-value arguments in addition to the input arguments in the previous syntax, for example, option to set the control variables in the new configuration.

    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,ConfigurationName="InternalPlantConfig", ...
     Description="Internal Plant Controller",ControlVariables=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

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: addConfiguration(varConfigData,ConfigurationName="LinExterHighFid",ControlVariables=ctrlVarStruct,Description="Linear controller and high fidelity external plant");

    Control variables in variant configuration, 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:

    • 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

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

    Example: "Linear configuration with internal plant"

    Data Types: char | string

    Version History

    Introduced in R2013b

    expand all