Determine class of object
ClassName
=
class(object)
obj = class(s,'class_name
')
obj = class(s,'class_name
',parent1,parent2,...)
obj = class(struct([]),'class_name
',parent1,parent2,...)
obj_struct = class(struct_array,'class_name
',parent_array)
returns a string specifying the class of ClassName
=
class(object)object
.
See Fundamental MATLAB Classes for
more information on MATLAB® classes.
Before MATLAB 7.6 (classes defined without a classdef
statement), class constructors
called the class
function to create the object.
The following class
function syntaxes apply only
within classes defined before Version 7.6.
obj = class(s,'
creates
an array of class class_name
')
objects
using the class_name
struct
s
as a pattern
to determine the size of obj
.
obj = class(s,'
inherits
the methods and fields of the parent objects class_name
',parent1,parent2,...)parent1
, parent2
,
and so on. The size of the parent objects must match the size of s
or
be a scalar (1-by-1), in which case MATLAB performs scalar expansion.
obj = class(struct([]),'
constructs
an object containing only fields that it inherits from the parent
objects. All parents must have the same, nonzero size, which determines
the size of the returned object class_name
',parent1,parent2,...)obj
.
obj_struct = class(struct_array,'
maps
every element of the class_name
',parent_array)parent_array
to a corresponding
element in the struct_array
to produce the output
array of objects, obj_struct
.
All arrays must be of the same size. If either the struct_array
or
the parent_array
is of size 1-by-1, then MATLAB performs
scalar expansion to match the array sizes.
To create an object array of size 0-by-0, set the size of the struct_array
and parent_array
to
0-by-0.
Return the class of Java® object obj
:
import java.lang.*; obj = String('mystring'); disp(class(obj)) java.lang.String
Return class of any MATLAB variable:
h = @sin; disp(class(h)) function_handle