setModelVariantControl - Configure Simulink.VariantControl object for code
generation - MATLAB ([original](https://www.mathworks.com/help/ecoder/ref/setmodelvariantcontrol.html)) ([raw](?raw))
Configure Simulink.VariantControl
object for code generation
Since R2025a
Syntax
Description
setModelVariantControl([codeMappingObj](#mw%5Fe96d0e88-825a-43cb-97cf-1d66ab409b48),[variantControl](#mw%5F308b7a67-3f6f-4f7e-9a4e-80cbf7480104),[Name=Value](#namevaluepairarguments))
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 itsValue
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.
Examples
Get the code mappings for modelslexVariantParameterCodeMappings
.
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
Name of Simulink.VariantControl
object, specified as a character vector or string scalar.
Example: "varCtrl"
Data Types: char
| string
Name-Value Arguments
Specify optional pairs of arguments asName1=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 classesExportToFile
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 classesExportToFile
, 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
andVolatile
.
Data Types: char
| string
When model configuration parameter Array layout is set toRow-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
) or0
(false
). This argument applies to storage classes ExportToFile
, GetSet
,ImportFromFile
, Localizable
, andVolatile
.
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 classesBitfield
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 inCompuMethod
of the variant control.
Data Types: char
| string
Data Types: char
| string
Version History
Introduced in R2025a