Main Content

removeEnumeral

Remove enumeration member from enumerated data type definition in data dictionary

Description

example

removeEnumeral(typeObj,memberNum) removes an enumeration member from the enumerated type definition stored by typeObj, a Simulink.data.dictionary.EnumTypeDefinition object.

Examples

collapse all

Create an object that can store the definition of an enumerated type. By default, the new type defines a single enumeration member enum1 with underlying integer value 0.

myColors = Simulink.data.dictionary.EnumTypeDefinition
myColors = 

   Simulink.data.dictionary.EnumTypeDefinition
      enum1

Add some enumeration members to the definition of the type.

appendEnumeral(myColors,'Orange',1,'')
appendEnumeral(myColors,'Black',2,'')
appendEnumeral(myColors,'Cyan',3,'')
myColors
myColors = 

   Simulink.data.dictionary.EnumTypeDefinition
      enum1
      Orange
      Black
      Cyan

Remove the default enumeration member enum1. Since enum1 is the first enumeration member in the list, identify it with index 1.

removeEnumeral(myColors,1)
myColors
myColors = 

   Simulink.data.dictionary.EnumTypeDefinition
      Orange
      Black
      Cyan

Customize the enumerated type by configuring the properties of the object representing it.

myColors.Description = 'These are my favorite colors.';
myColors.DefaultValue = 'Cyan';
myColors.HeaderFile = 'colorsType.h';

Open the data dictionary myDictionary_ex_API.sldd and represent it with a Simulink.data.Dictionary object named myDictionaryObj.

myDictionaryObj = Simulink.data.dictionary.open('myDictionary_ex_API.sldd');

Import the object that defines the enumerated type myColors to the dictionary.

importFromBaseWorkspace(myDictionaryObj,'varList',{'myColors'});

Input Arguments

collapse all

Target enumerated type definition, specified as a Simulink.data.dictionary.EnumTypeDefinition object.

Index of target enumeration member, specified as an integer.

The first enumeration member in an enumerated type definition has index 1. For example, suppose an enumerated type BasicColors has this definition:

myColors = 

   Simulink.data.dictionary.EnumTypeDefinition
      Orange
      Black
      Cyan

To remove the enumeration member Black, specify memberNum as 2. To remove the enumeration member Cyan, specify 3.

Do not specify memberNum using the integer value underlying an enumeration member. The integer value underlying the member is not equivalent to the index of the member.

Example: 3

Data Types: single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | double

Alternatives

You can use Model Explorer to remove enumeration members from the enumerated data type represented by a Simulink.data.dictionary.EnumTypeDefinition object.

Version History

Introduced in R2015a