主要内容

getReferencedConfigurationName

R2026b

Get name of variant configuration used by referenced component in model hierarchy

Renamed from getComponentConfigurationName in R2026b

    Description

    In a model that has predefined variant configurations and also has a referenced model in its model hierarchy, the referenced model can define its own variant configurations. While authoring the variant configurations for the top-level model, you can associate a referenced model configuration with a top-level variant configuration to populate the corresponding control variables in the top-level configuration. Use the getReferencedConfigurationName function to get the name of the referenced model configuration used within a top-level variant configuration. For more information, see Compose Variant Configurations and Constraints for Top Model Using Referenced Configurations.

    refConfigName = getReferencedConfigurationName(varConfigsTop,ConfigurationName=topMdlConfig,ReferencedComponentName=refMdlName) returns the name of the variant configuration used by the referenced component refMdlName in the top-level model variant configuration topMdlConfig. The variant configuration topMdlConfig must be defined in varConfigsTop, the Simulink.VariantConfigurations object associated with the top-level model.

    example

    Examples

    collapse all

    Open the slexVariantManagement model.

    modelName="slexVariantManagement";
    open_system(modelName);

    LinExterHighFid is a variant configuration defined for the top-level model slexVariantManagement and is present in the variant configurations object vco.

    vco = Simulink.VariantManager.getVariantConfigurations("slexVariantManagement");

    Get the name of the variant configuration used by the referenced component slexVariantManagementExternalPlantMdlRef in the variant configuration LinExterHighFid.

    refSelectedConfig = getReferencedConfigurationName ...
        (vco,ConfigurationName="LinExterHighFid", ...
        ReferencedComponentName="slexVariantManagementExternalPlantMdlRef");

    Input Arguments

    collapse all

    Variant configurations object of the top-level model, specified as a Simulink.VariantConfigurations object.

    Name of the variant configuration of top-level model from which the configuration used by the referenced component refMdlName is retrieved, specified as a character vector or string scalar. topMdlConfig must be defined in varConfigsTop.

    Example: "LinExterHighFid"

    Data Types: char | string

    Name of a referenced component in the model hierarchy of the top-level model, such as a referenced model, specified as a character vector or string scalar.

    Example: "slexVariantManagementExternalPlantMdlRef"

    Data Types: char | string

    Output Arguments

    collapse all

    Name of variant configuration used by referenced component, returned as a character vector or string scalar.

    Version History

    Introduced in R2023b

    expand all