Simulink.defineIntEnumType

Define enumerated data type

Syntax

Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues)
Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'Description', ClassDesc)
Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'DefaultValue', DefValue)
Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'DataScope', ScopeSelection)
Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'HeaderFile', FileName)
Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'AddClassNameToEnumNames', Flag)
Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'StorageType', DataType)

Description

Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues) defines an enumeration named ClassName with enumeration values specified with CellOfEnums and underlying numeric values specified by IntValues.

Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'Description', ClassDesc) defines the enumeration with a description (character vector).

Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'DefaultValue', DefValue) defines a default value for the enumeration, which is one of the character vectors you specify for CellOfEnums.

Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'DataScope', ScopeSelection) specifies whether the data type definition should be imported from, or exported to, a header file during code generation.

Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'HeaderFile', FileName) specifies the name of a header file containing the enumeration class definition for use in code generated from a model.

Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'AddClassNameToEnumNames', Flag) specifies whether the code generator applies the class name as a prefix to the enumeration values that you specify for CellOfEnums. For Flag, specify true or false. For example, if you specify true, the code generator would use BasicColors.Red instead of Red to represent an enumerated value.

Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'StorageType', DataType) specifies the data type used to store the enumerations’ underlying integer values in code generated from a model.

Input Arguments

ClassName

The name of the enumerated data type.

CellOfEnums

A cell array of character vectors that defines the enumerations for the data type.

IntValues

An array of numeric values that correspond to enumerations of the data type.

'Description', ClassDesc

Specifies a character vector that describes the enumeration data type.

'DefaultValue', DefValue

Specifies the default enumeration value.

'HeaderFile', FileName

Specifies a character vector naming the header file that is to contain the data type definition.

By default, the generated #include directive uses the preprocessor delimiter " instead of < and >. To generate the directive #include <myTypes.h>, specify FileName as '<myTypes.h>'.

'DataScope', 'Auto' | 'Exported' | 'Imported'

Specifies whether the data type definition should be imported from, or exported to, a header file during code generation.

ValueAction
Auto (default)

If no value is specified for Headerfile, export the type definition to model_types.h, where model is the model name.

If a value is specified for Headerfile, import the data type definition from the specified header file.

Exported

Export the data type definition to a header file.

If no value is specified for Headerfile, the header file name defaults to type.h, where type is the data type name.

Imported

Import the data type definition from a header file.

If no value is specified for Headerfile, the header file name defaults to type.h, where type is the data type name.

'AddClassNameToEnumNames', Flag

A logical flag that specifies whether code generator applies the class name as a prefix to the enumerations.

'StorageType', DataType

Specifies a character vector that identifies the data type used to store the enumerations’ underlying integer values in generated code. The following data types are supported: 'int8', 'int16', 'int32', 'uint8', or 'uint16'.

Examples

Assume an external data dictionary includes the following enumeration:

BasicColors.Red(0), BasicColors.Yellow(1), BasicColors.Blue(2)

Import the enumeration class definition into the MATLAB® workspace while specifying int16 as the underlying integer data type for generated code:

Simulink.defineIntEnumType('BasicColors', ... 
	{'Red', 'Yellow', 'Blue'}, ...
	[0;1;2], ... 
	'Description', 'Basic colors', ...
	'DefaultValue', 'Blue', ...
	'HeaderFile', 'mybasiccolors.h', ...
	'DataScope', 'Exported', ...
	'AddClassNameToEnumNames', true, ...
	'StorageType', 'int16');
Introduced in R2010b