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
    Name of source definition file that contains definitions for global data that is read by the variant parameter and external codeDefinitionFile
    Name of get function called by code generated for the variant parameterGetFunction
    Name of source header file that contains declarations for global data that is read by the variant parameter and external codeHeaderFile
    Name of model for which the code generator places the definition for the variant parameter shared by multiple models in a model hierarchyOwner
    Boolean value indicating whether the code generator preserves dimensions of a variant parameter that is represented as a multidimensional arrayPerserveDimensions
    Name of set function called by code generated for the variant parameterSetFunction
    Name of structure in generated code for the variant parameterStructName
    Name of parameter argument tuning service defined in Embedded Coder DictionaryParameterArgumentTuningService
    Name of parameter tuning service defined in Embedded Coder DictionaryParameterTuningService

    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