Class of object
Get the class name of a Java object.
jObject = java.lang.String('Java string');
className = class(jObject);
disp(className)
java.lang.String
Determine the class of a variable.
h = @sin; className = class(h); disp(className)
function_handle
obj
— Object or literalObject or literal, specified as a variable or an expression.
Example: class(date)
className
— Name of the className of the class, returned as a character vector.
In class definition 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,ClassName)
creates an array of objects of the
specified class using the struct
s
as a pattern to determine the size of obj
.
obj = class(s,ClassName,parent1,parent2,...)
inherits the
methods and fields of the specified parent objects. The size of the parent objects
must match the size of s
or be a scalar (1-by-1). If they are
scalar, MATLAB performs scalar expansion.
obj = class(struct([]),ClassName,parent1,parent2,...)
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.
objStruct = class(structArray,ClassName,parentArray)
maps every
element of the parentArray
to a corresponding element in the
structArray
to produce the output array of objects,
objStruct
.
All arrays must be of the same size. If either the structArray
or the parentArray
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
structArray
and parentArray
to
0-by-0.
You have a modified version of this example. Do you want to open this example with your edits?