This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

coder.EnumType class

Package: coder
Superclasses: coder.ArrayType

Represent set of MATLAB enumerations

Description

Specifies the set of MATLAB® enumerations that the generated code should accept. Use only with the fiaccel -args options. Do not pass as an input to a generated MEX function.

Construction

enum_type = coder.typeof(enum_value) creates a coder.EnumType object representing a set of enumeration values of class (enum_value).

enum_type = coder.typeof(enum_value, sz, variable_dims) returns a modified copy of coder.typeof(enum_value) with (upper bound) size specified by sz and variable dimensions variable_dims. If sz specifies inf for a dimension, then the size of the dimension is unbounded and the dimension is variable size. When sz is [], the (upper bound) sizes of v do not change. If you do not specify variable_dims, the bounded dimensions of the type are fixed; the unbounded dimensions are variable size. When variable_dims is a scalar, it applies to bounded dimensions that are not 1 or 0 (which are fixed).

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

Input Arguments

enum_value

Enumeration value defined in a file on the MATLAB path.

sz

Size vector specifying each dimension of type object.

Default: [1 1] for coder.newtype

variable_dims

Logical vector that specifies whether each dimension is variable size (true) or fixed size (false).

Default: false(size(sz)) | sz==Inf for coder.newtype

enum_name

Name of enumeration defined in a file on the MATLAB path.

Properties

ClassName

Class of values in the set.

SizeVector

The upper-bound size of arrays in the set.

VariableDims

A vector specifying whether each dimension of the array is fixed or variable size. If a vector element is true, the corresponding dimension is variable size.

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects (MATLAB).

Examples

Create a coder.EnumType object using a value from an existing MATLAB enumeration.

  1. Define an enumeration MyColors. On the MATLAB path, create a file named 'MyColors' containing:

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

  2. Create a coder.EnumType object from this enumeration.

    t = coder.typeof(MyColors.red);

Create a coder.EnumType object using the name of an existing MATLAB enumeration.

  1. Define an enumeration MyColors. On the MATLAB path, create a file named 'MyColors' containing:

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

  2. Create a coder.EnumType object from this enumeration.

    t = coder.newtype('MyColors');

Introduced in R2011a