Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

class - Determine class name of object

Syntax


str = 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)

Description

str = class(object) returns a string specifying the class of object. See Classes (Data Types) 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 uses of class apply to classes defined before Version 7.6.

obj = class(s,'class_name') creates an array of class class_name objects using the struct s as a pattern to determine the size of obj.

obj = class(s,'class_name',parent1,parent2,...) inherits the methods and fields of the parent objects 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([]),'class_name',parent1,parent2,...) constructs 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 obj.

obj_struct = class(struct_array,'class_name',parent_array) maps every element of the 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.

Examples

Return the class of Java object obj:

import java.lang.*;
obj = String('mystring');
class(obj)

ans =

java.lang.String

Return class of any MATLAB variable:

h = @sin;
class(h)

ans =

function_handle

See Also

isa | isobject | metaclass

Tutorials

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS