class
Class of object
Syntax
Description
Examples
Class of Java Object
Get the class name of a Java® object.
jObject = java.lang.String('Java string');
className = class(jObject);
disp(className)
java.lang.String
Class of a Variable
Determine the class of a variable.
h = @sin; className = class(h); disp(className)
function_handle
Input Arguments
obj
— Object or literal
variable or expression
Object or literal, specified as a variable or an expression.
Example: class(date)
Output Arguments
className
— Name of the class
character vector
Name of the class, returned as a character vector.
More About
Obsolete Class Definition Syntax
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.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)