| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
Meta-classes are classes that contain information about class definitions. Each block in a class definition has an associated meta-class that defines the attributes for that block. Each attribute corresponds to a property in the meta-class. An instance of a meta-class has values assigned to each property that correspond to the values of the attributes of the associated class block.
Meta-classes enable programmatic inspection of classes and objects. Tools such as property inspectors, debuggers, and so on, use these techniques.
The meta package contains meta-classes that MATLAB uses for the definition of classes and class components. The class name indicates the component described by the meta-class:
meta.package meta.class meta.property meta.method meta.event
Each meta-class has properties, methods, and events that contain information about the class or class component. See meta.package, meta.class, meta.property, meta.method and meta.event for more information on these meta-classes.
You cannot instantiate meta-classes directly by calling the respective class constructor. You can create meta-class objects from class instances or from the class name.
?ClassName — Returns a meta.class object for the named class. Use meta.class.fromName with class names stored as characters in variables.
meta.class.fromName('ClassName') — returns the meta.class object for the named class (meta.class.fromName is a meta.class method).
metaclass(obj) — Returns a meta-class object for the class instance (metaclass)
% create meta-class object from class name using the ? operator mobj = ?classname; % create meta-class object from class name using the fromName method mobj = meta.class.fromName('classname'); % create meta-class object from class instance obj = myClass; mobj = metaclass(obj);
The metaclass function returns the meta.class object (that is, an object of the meta.class class). You can obtain other meta-class objects (meta.property, meta.method, and so on) from the meta.class object.
Note Meta-class is a term used here to describe a kind of class. meta.class is a class in the meta package whose instances contain information about MATLAB classes. |
Here is how you can use meta-class objects:
Obtain a meta.class object from a class definition (using ?) or from a class instance (using metaclass).
Use the meta.class properties, methods, and events to obtain information about the class or class instance from which you obtained the meta.class object. For example, get other meta-class objects, such as the meta.properties objects defined for each of the class properties.
The following examples show these techniques.
![]() | Obtaining Information About Classes with Meta-Classes | Using Meta-Classes to Inspect Classes and Objects | ![]() |

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 |