isenum

Tests whether a value is an instance of an enumeration class.

Category: Language Fundamentals > Data Types

Syntax

tf = isenum(A)

Returns true if A is a member of an enumeration class.

Description

Enumeration classes are classdef classes declared with an enumeration block. Only their members make isenum return true. Built-in types such as numbers, text and categorical arrays give false, even though a categorical array also holds a fixed set of named values.

Input arguments

A
Any value.

Output arguments

tf
Logical scalar.

Example

Ordinary values are not enumerations

isenum(1)
isenum('text')
isenum(categorical({'a','b'}))
Output
ans = logical
   0
ans = logical
   0
ans = logical
   0

See also

enumeration categorical isobject class