Skip to Main Content Skip to Search
Product Documentation

Use Class Metadata

What Is Class Metadata?

Class metadata is information about class definitions that is available from instances of metaclasses. Use metaclass objects to obtain information about class definitions without the need to create instances of the class itself.

Each block in a class definition has an associated metaclass that defines the attributes for that block. Each attribute corresponds to a property in the metaclass. An instance of a metaclass has values assigned to each property that correspond to the values of the attributes of the associated class block.

Metadata enables the programmatic inspection of classes. Tools such as property inspectors, debuggers, and so on, use these techniques.

The meta Package

The meta package contains metaclasses that MATLAB uses for the definition of classes and class components. The class name indicates the component described by the metaclass:

meta.package
meta.class
meta.property
meta.DynamicProperty
meta.EnumeratedValue
meta.method
meta.event

Each metaclass has properties, methods, and events that contain information about the class or class component. See meta.package, meta.class, meta.property, meta.DynamicProperty, meta.EnumeratedValue, meta.method and meta.event for more information on these metaclasses.

Creating Metaclass Objects

You cannot instantiate metaclasses directly by calling the respective class constructor. You can create metaclass objects from class instances or from the class name.

% create metaclass object from class name using the ? operator
mobj = ?classname; 
% create metaclass object from class name using the fromName method
mobj = meta.class.fromName('classname'); 
% create metaclass 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 metaclass objects (meta.property, meta.method, and so on) from the meta.class object.

Using Metaclass Objects

Here are ways to access the information in metaclass objects:

See the following sections for examples that show how to use metadata:

  


Recommended Products

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

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