class
Name of the class of a value.
Category: Language Fundamentals > Data Types
Syntax
c = class(obj)
Returns the class name as a character vector.
Description
class identifies the data type used to store the value, regardless of its size. Literals like 1 are double, 'a' is char, "a" is string, and true is logical. Objects such as tables and datetimes return their own class names.
Use isa(x, 'numeric') to test against a group of classes, and cast to convert.
Input arguments
obj- Any value.
Output arguments
c- Character vector such as
'double','char','cell','struct'or'function_handle'.
Example
Classes of common values
class(1:3)
class('a')
class("a")
class(@sin)
class(int8(1))
class({})
Output
ans = 'double'
ans = 'char'
ans = 'string'
ans = 'function_handle'
ans = 'int8'
ans = 'cell'