Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Contents

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, 'HeaderFile', FileName)
Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'AddClassNameToEnumNames', Flag)

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 (string).

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

Simulink.defineIntEnumType(ClassName, CellOfEnums, IntValues, 'HeaderFile', FileName) specifies a header file into which the code generator places the enumeration class definition.

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.

Input Arguments

ClassName

The name of the enumerated data type.

CellOfEnums

A cell array of strings 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 string that describes the enumeration data type.

'DefaultValue', DefValue

Specifies the default enumeration value.

'HeaderFile', FileName

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

'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.

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:

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

See Also

Was this topic helpful?