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

    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.

    Version History

    Introduced in R2025a