| Programming and Data Types | ![]() |
Identifying Objects Outside the Class Directory
The class and isa functions used in constructor methods can also be used outside of the class directory. The expression
isa(a,'class_name');
checks whether a is an object of the specified class. For example, if p is a polynom object, each of the following expressions is true.
isa(pi,'double');isa('hello','char');isa(p,'polynom');
Outside of the class directory, the class function takes only one argument (it is only within the constructor that class can have more than one argument).
class(a);
returns a string containing the class name of a. For example,
class(pi),class('hello'),class(p)
'double','char','polynom'
Use the whos function to see what objects are in the MATLAB workspace.
whos Name Size Bytes Class p 1x1 156 polynom object
| The Class Constructor Method | The display Method | ![]() |