Main Content

setPreferredConfiguration

Set name of preferred variant configuration for variant configuration data object

Since R2022b

    Description

    Note

    This function requires Variant Manager for Simulink®.

    setPreferredConfiguration(varconfigdata,nameofconfig) sets nameofconfig as the preferred variant configuration for the Simulink.VariantConfigurationData object varconfigdata.

    example

    Examples

    collapse all

    Open the model slexVariantManagement.

    model = "slexVariantManagement";
    open_system(model);

    Get the variant configuration data object associated with the model.

    varconfigdata = Simulink.VariantManager.getConfigurationData(model);

    Set the name of the preferred variant configuration for the variant configuration data object.

    setPreferredConfiguration(varconfigdata,"LinInterExpNoNoise");

    Apply the preferred variant configuration and compile the model.

    Simulink.VariantManager.applyConfiguration(model, ...
     "Configuration",getPreferredConfiguration(varconfigdata));
    set_param(model,SimulationCommand="Update");

    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 preferred variant configuration, specified as a character vector or string scalar.

    Example: "LinInterExpNoNoise"

    Data Types: char | string

    Version History

    Introduced in R2022b