Documentation

Simulink.data.getEnumTypeInfo

Get information about enumerated data type

Syntax

信息= Simulink.d万博1manbetxata.getEnumTypeInfo (enumTypeName,infoRequest)

Description

example

information= Simulink.data.getEnumTypeInfo(enumTypeName,infoRequest)returns information about an enumerated data typeenumTypeName.

Use this function only to return information about an enumerated data type. To customize an enumerated data type, for example, by specifying a default enumeration member or by controlling the scope of the type definition in generated code, seeCustomize Simulink Enumeration.

Examples

collapse all

Get the default enumeration member of an enumerated data typeLEDcolor. SupposeLEDcolordefines two enumeration members,GREENandRED, and usesGREENas the default member.

Simulink.data.getEnumTypeInfo('LEDcolor','DefaultValue')
ans = GREEN

For an enumerated data typeLEDcolor, find out if generated code exports or imports the definition of the type to or from a header file.

Simulink.data.getEnumTypeInfo('LEDcolor','DataScope') Simulink.data.getEnumTypeInfo('LEDcolor','HeaderFile')
ans = Auto ans = ''

BecauseDataScopeis'Auto'andHeaderFileis empty, generated code defines the enumerated data typeLEDcolorin the header filemodel_types.hwheremodelis the name of the model used to generate code.

Input Arguments

collapse all

Name of the target enumerated data type, specified as a character vector.

Example:'myFirstEnumType'

Data Types:char

Information to return, specified as one of the character vector options in the table.

Specified value Information returned Example return value
'DefaultValue' The default enumeration member, returned as an instance of the enumerated data type. enumMember1
'Description' The custom description of this data type, returned as a character vector. Returns an empty character vector if a description was not specified for the type. 'My first enum type.'
'HeaderFile' The name of the custom header file that defines the data type in generated code, returned as a character vector. Returns an empty character vector if a header file was not specified for the type. 'myEnumType.h'
'DataScope' Indication whether generated code imports or exports the definition of the data type. A return value of'Auto'indicates generated code defines the type in the header filemodel_types.hor imports the definition from the header file identified byHeaderFile. A return value of'Exported'or'Imported'indicates generated code exports or imports the definition to or from the header file identified byHeaderFile. 'Exported'
'StorageType' The integer data type used by generated code to store the numeric values of the enumeration members, returned as a character vector. Returns'int'if you did not specify a storage type for the enumerated type, in which case generated code uses the native integer type of the hardware target. 'int32'
“AddClassNameToEnumNames' Indication whether generated code prefixes the names of enumeration members with the name of the data type. Returned astrueorfalse. true

Introduced in R2014b

Was this topic helpful?