Main Content

getModelVariantVariable

Get code configuration from code mappings for Simulink.VariantVariable object

Since R2025a

    Description

    propertyValue = getModelVariantVariable(codeMappingObj,variantVariable,property) returns the value of a code mapping property for the specified Simulink.VariantVariable object variantVariable (also referred to as a variant parameter) from the code mapping codeMappingObj. A Simulink.VariantVariable object derives its code mappings from the Simulink.Parameter object that is used to set the Specification property of the object. The getModelVariantVariable function returns the storage class and storage class property settings configured for the Simulink.VariantVariable object from this Simulink.Parameter object. For code mappings support, the Simulink.VariantVariable object and its associated Simulink.VariantControl and Simulink.Parameter objects must be defined in the model workspace of the model.

    example

    Examples

    collapse all

    From the model code mappings for the model slexVariantParameterCodeMappings, get the name of the storage class of the variant variable GearRatio.

    openExample("simulinkcoder/ConfigureCodeGenForVariantParametersInModelWorkspaceExample");
    cm = coder.mapping.api.get("slexVariantParameterCodeMappings");
    getModelVariantVariable(cm,"GearRatio","StorageClass");

    Input Arguments

    collapse all

    Code mapping object (model code mappings) returned by a call to function coder.mapping.api.get.

    Name of Simulink.VariantVariable object, specified as a character vector or string scalar.

    Example: "GearRatio"

    Data Types: char | string

    Code mapping property name. The getModelVariantVariable function returns the value of this property. For a storage class defined in the Embedded Coder Dictionary associated with the model, specify a property name or one of these property names.

    Information to ReturnProperty Name
    Name of storage classStorageClass
    Name of variable for the variant parameter in the generated codeIdentifier

    Example: "StorageClass"

    Output Arguments

    collapse all

    Name of the storage class or value of the specified storage class property configured for the Simulink.VariantVariable object, returned as a character vector.

    Version History

    Introduced in R2025a