MATLAB Function Reference    
class

Create object or return class of object

Syntax

Description

str = class(object) returns a string specifying the class of object.

The following table lists the object class names that may be returned. All except the last one are MATLAB classes.

cell
Cell array
char
Characters array
double
Double-precision floating point number array
int8
8-bit signed integer array
int16
16-bit signed integer array
int32
32-bit signed integer array
sparse
2-D real (or complex) sparse array
struct
Structure array
uint8
8-bit unsigned integer array
uint16
16-bit unsigned integer array
uint32
32-bit unsigned integer array
'matlab_class_name'
Name of user-defined MATLAB class
'java_class_name'
Name of Java class

obj = class(s,'class_name') creates an object of MATLAB class 'class_name' using structure s as a template. This syntax is valid only in a function named class_name.m in a directory named @class_name (where 'class_name' is the same as the string passed into class).

obj = class(s,'class_name',parent1,parent2,...) creates an object of MATLAB class 'class_name' that inherits the methods and fields of the parent objects parent1, parent2, and so on. Structure s is used as a template for the object.

obj = class(struct([]),'class_name',parent1,parent2,...) creates an object of MATLAB class 'class_name' that inherits the methods and fields of the parent objects parent1, parent2, and so on. Specifying the empty structure, struct([]), as the first argument ensures that the object created contains no fields other than those that are inherited from the parent objects.

Examples

To return in nameStr the name of the class of Java object j

To create a user-defined MATLAB object of class polynom

See Also

inferiorto, isa, superiorto

The MATLAB Classes and Objects and the Calling Java from MATLAB chapters in Programming and Data Types.


 clabel clc