Main Content

setModelVariantControl

Configure Simulink.VariantControl object for code generation

Since R2025a

    Description

    setModelVariantControl(codeMappingObj,variantControl,Name=Value) configures the specified Simulink.VariantControl object variantControl in the code mappings codeMappingObj for code generation. Specifying code generation attributes for a Simulink.VariantControl object using code mappings is supported when the object is defined in the model workspace and its Value property is set to a Simulink.Parameter object. Use this function to map the specified variant control to the storage class and storage class property settings that the code generator uses to produce C code.

    example

    Examples

    collapse all

    Get the code mappings for model slexVariantParameterCodeMappings.

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

    Set the storage class for the variant control named Wiper defined in the model workspace to ExportedGlobal.

    setModelVariantControl(cm,"Wiper",StorageClass="ExportedGlobal");

    Input Arguments

    collapse all

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

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

    Example: "varCtrl"

    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: StorageClass="ExportedGlobal"

    Storage class to set for the specified variant control. StorageClass is the name of a predefined storage class or a storage class that is defined in the Embedded Coder Dictionary associated with the model. See Configure Parameters for C Code Generation.

    Name for the variable that represents the variant control in the generated code, specified as a character vector or string scalar.

    Data Types: char | string

    File name for a C source file that contains definitions for global data read by data elements and external code, specified as a character vector or string scalar. This argument applies to storage classes ExportToFile and Volatile.

    Data Types: char | string

    Name of a get function that a data element calls in the generated code, specified as a character vector or string scalar. This argument applies to the storage class GetSet.

    Data Types: char | string

    File name for a C header file that contains declarations for global data read by data elements and external code, specified as a character vector or string scalar. This argument applies to storage classes ExportToFile, GetSet, ImportFromFile, and Volatile.

    Data Types: char | string

    Name of the model that owns global data used by other models in the same model hierarchy, specified as a character vector or string scalar. The code generated for the model that owns the data includes the global data definition. This argument applies to storage classes ExportToFile and Volatile.

    Data Types: char | string

    When model configuration parameter Array layout is set to Row-major,option to preserve dimensions of a data element that is represented in generated code as a multidimensional array, specified as a numeric or logical 1 (true) or 0 (false). This argument applies to storage classes ExportToFile, GetSet, ImportFromFile, Localizable, and Volatile.

    Data Types: logical

    Name of a set function that a data element calls in the generated code, specified as a character vector or string scalar. This argument applies to the storage class GetSet.

    Data Types: char | string

    Name that the code generator uses to identify the structure for a data element in the generated code. This argument applies to storage classes Bitfield and Struct.

    Data Types: char | string

    Value of storage class property defined in the Embedded Coder Dictionary. Values that you can specify vary depending on the storage class definition.

    Note

    For an element associated with the custom storage class where Type is set to Other , create a custom attributes class for the custom storage class and associate the custom attributes class with a Boolean property, SupportSILPIL set to true. For more information, see Interfaces That Produce Additional Generated Code.

    Option to enable or disable generation of the model parameter to an A2L calibration file, specified as a numeric or logical 1 (true) or 0 (false).

    Mask value to extract single bits from the variant control during calibration, specified as integer in hexadecimal format. This property is applicable only for integers.

    Data Types: hexadecimal

    Option to enable or disable calibration of the variant control, specified as one of these values:

    • "Calibration" — Enable calibration.

    • "NoCalibration" — Disable calibration.

    Name of the method for converting the ECU-internal value to a physical value for easy readability, specified as a character vector or string scalar.

    Data Types: char | string

    Optional display name of the variant control for measurement purpose in the calibration tool, which is different than the variant control name in the Simulink model, specified as a character vector or string scalar.

    Data Types: char | string

    Special display format to be specified for measurement in the calibration tool. This format specification overrules the display format specified in CompuMethod of the variant control.

    Name of a parameter tuning service interface defined in the Embedded Coder Dictionary, specified as a character vector or string scalar. To use the dictionary default, specify "Dictionary default".

    To configure the parameter tuning service interface, attach an Embedded Coder Dictionary that defines a service interface configuration to the model. For more information, see Configure Parameter and Parameter Argument Tuning Service Interfaces for Model Parameters and Model Parameter Arguments.

    Data Types: char | string

    Name of a parameter argument tuning service interface defined in the Embedded Coder Dictionary, specified as a character vector or string scalar. To use the dictionary default, specify "Dictionary default".

    To configure the parameter argument tuning service interface, attach an Embedded Coder Dictionary that defines a service interface configuration to the model. For more information, see Configure Parameter and Parameter Argument Tuning Service Interfaces for Model Parameters and Model Parameter Arguments.

    Data Types: char | string

    Version History

    Introduced in R2025a