Main Content

coder.EnumType class

Package: coder
Superclasses: coder.ArrayType

Represent set of MATLAB enumerations acceptable for input specification

Description

Objects of the coder.EnumType class specify the MATLAB® enumerations that the generated code accepts. Use objects of this class only with the -args option of the codegen command. Do not pass as an input to a generated MEX function.

Creation

t = coder.typeof(enumValue) creates a coder.EnumType object that represents a set of enumeration values of class enumValue.

t = coder.typeof(enumValue,sz,variableDims) creates a coder.EnumType type object with upper bound sizes sz and variable dimensions indicated in variableDims. If sz specifies inf for a dimension, then the size of the dimension is unbounded and the dimension has a variable size. When sz is [], the upper bound sizes of v do not change. If you do not specify variableDims, the bounded dimensions of the type are fixed and the unbounded dimensions have a variable size. When variableDims is a scalar, the function applies this value to bounded dimensions that are not 1 or 0, which are fixed.

t = coder.newtype(enumName,sz,variableDims) creates a coder.EnumType object that has a variable size with upper bound sizes sz and variable dimensions variableDims. If sz specifies inf for a dimension, then the size of the dimension is unbounded and the dimension has a variable size. If you do not specify variableDims, the bounded dimensions of the type are fixed. When variableDims is a scalar, the function applies this value to bounded dimensions that are not 1 or 0, which are fixed.

Input Arguments

expand all

Enumeration value defined on the MATLAB path, specified as an enumeration object.

Dimension of type object, specified as a vector of positive integers or scalar positive integer.

Option to specify whether each dimension has a variable size, specified as a boolean vector. If you specify an element of this vector as 1, the corresponding dimension has a variable size. Otherwise, the dimension has a fixed size.

Name of enumeration defined on the MATLAB path, specified as a string scalar or character vector.

Properties

expand all

Class of values in the set, returned as a string scalar or character vector.

Upper bound size of the arrays in the set, specified as a vector of integers.

Indication of whether each dimension of the array has fixed or variable size. If a vector element is 1, the corresponding dimension has variable size. Otherwise, the dimension has a fixed-size.

Examples

collapse all

On the MATLAB® path, define an enumeration named MyColors.

type MyColors.m
classdef MyColors < int32
    enumeration
        green(1),
        red(2),
    end
end

Create a coder.EnumType object from this enumeration by using coder.typeof.

t = coder.newtype('MyColors')
t = 
coder.EnumType
   1×1 MyColors

Version History

Introduced in R2011a