Main Content

convertDefaultToPreferred

Convert default variant configuration to preferred variant configuration

Since R2022b

    Description

    DefaultConfiguration property of a variant configuration data object will be removed. Use the PreferredConfiguration property instead (since R2022b) to indicate the configuration that is suited for the model for common workflows. If the variant configuration data object associated with your model has a value set for the DefaultConfiguration property, you can use it to set the PreferredConfiguration property using the convertDefaultToPreferred function.

    For more information, see DefaultConfigurationName and SubModelConfiguration properties will be removed.

    Note

    This function requires Variant Manager for Simulink®.

    convertDefaultToPreferred(varconfigdata) sets the value of the PreferredConfiguration property of varconfigdata to the value of the DefaultConfiguration property, and then clears the DefaultConfiguration property. varconfigdata is a Simulink.VariantConfigurationData object.

    convertDefaultToPreferred(varconfigdata,model,Name=Value) specifies options using one or more name-value arguments to additionally activate the preferred variant configuration on model by updating the callback functions of the model.

    The preferred variant configuration is not applied automatically when compiling or simulating a model. You must apply the preferred configuration explicitly on the model, if required. To additionally activate the preferred configuration on the model, you can set the Name=Value arguments in this function to add commands to the PostLoadFcn or InitFcn callbacks or both.

    example

    Examples

    collapse all

    Convert an existing default configuration of a variant configuration data object to its preferred configuration, and clear the default configuration.

    convertDefaultToPreferred(varconfigdata);

    Convert the configuration and update both the InitFcn and PostLoadFcn callbacks of the model modelname to activate the preferred configuration.

    convertDefaultToPreferred(varconfigdata,modelname, ...
     AddActivateToPostLoadFcn=true,AddActivateToInitFcn=true);

    Input Arguments

    collapse all

    Variant configuration data for which you want to set the preferred configuration, specified as a Simulink.VariantConfigurationData object.

    Name of the model with which varconfigdata is associated, specified as a character vector or string scalar.

    Example: "slexVariantManagement"

    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: AddActivateToPostLoadFcn=true

    Option to activate the preferred configuration by adding commands to the PostLoadFcn callback of the model, specified as a numeric or logical 1 (true) or 0 (false).

    Example: true

    Data Types: logical

    Option to activate the preferred configuration by adding commands to the InitFcn callback of the model, specified as a numeric or logical 1 (true) or 0 (false).

    Example: true

    Data Types: logical

    Version History

    Introduced in R2022b