Main Content

meta.class class

Package: meta
Superclasses: meta.MetaData

Describe MATLAB class


The meta.class class provides a way to get descriptive information about MATLAB® classes. By creating a meta.class object for a specific class, you can get information about the class definition.

Some properties of a meta.class object contain the values of class attributes defined in the corresponding MATLAB class. Query these properties for information that is specified syntactically by the class definition on the classdef line.

Other properties contain lists of properties, methods, and events defined by the class, as well as other information about how the class is defined.

You cannot set the values of meta.class object properties. You can only query the properties.

Create a meta.class object from an instance of a class or using the class name using these options:

  • metaclass(obj) — returns a meta.class object representing the object passed as an argument.

  • ?ClassName — returns a meta.class object representing the named class.

  • meta.class.fromName('ClassName') — static method returns a meta.class object representing the named class.

You cannot instantiate a meta.class object directly by calling its constructor.

The meta.class class is a handle class.

Class Attributes


For information on class attributes, see Class Attributes.


expand all

Value of class abstract attribute, returned as a logical value. The value of this property is true if the class or any property or method has its Abstract attribute set to true. For information on abstract classes, see Abstract Classes and Class Members.

Example: classdef (Abstract = true) ...

Data Types: logical

Call constructor on load, returned as a logical value. If true, MATLAB calls the class constructor automatically when loading an object from a MAT-file. To enable ConstructOnLoad, the constructor must support being called with no input arguments. For more information, see Save and Load Process for Objects.

Example: classdef (ConstructOnLoad = true) ...

Data Types: logical

Package containing class, returned as a meta.package object. If the class is not in a package this property contains an empty meta.package object. For more information about packages, see Packages Create Namespaces.

Data Types: meta.package

Currently not used.

Currently not used.

Is class an enumeration class, returned as a logical value. If true, this class is an enumeration class. For more information about enumeration classes, see Define Enumeration Classes.

Data Types: logical

Name and hidden status for enumeration members, returned as an array of meta.EnumeratedValue objects. Access the Name and Hidden properties of the corresponding member meta.EnumeratedValue object to obtain information. For more information, see Enumerations.

Data Types: meta.EnumeratedValue

Events defined for the class, including all inherited events, returned as an array of meta.event objects. Only handle classes can define events so this property is an empty meta.event object for value classes. All handle classes inherit the ObjectBeingDestroyed event. For more information about events, see Events.

Data Types: meta.event

Is class hidden from inspection tools, returned as logical true or false. When set to true, the class does not appear in the output of MATLAB commands or tools that display class names. However, you can access the class programmatically.

Data Types: logical

Classes specified as inferior to this class, returned as a cell array of meta.class objects. For information on class precedence, see Class Precedence.

Example: classdef (InferiorClasses = {?ClassName1,?ClassName2}) ...

Data Types: meta.class

Methods defined for the class, returned as an array of meta.method objects. The meta.method objects describe each method defined by this class, including inherited public and protected methods. For more information on methods, see Methods in Class Design.

Data Types: meta.method

Name of the class, returned as a character vector. The class name returned by this property does not include any packages that contain the class.

Data Types: char

Properties defined for the class, returned as an array of objects describing each property, including all inherited public and protected properties. For more information on properties, see Properties.

Data Types:

Does class restrict subclassing, returned as a logical true or false. MATLAB sets this attribute to true when the class restricts subclassing by:

  • Setting the Sealed attribute to true

  • Specifying the classes that can subclass this class using the AllowedSubclasses attribute

For more information restricting subclassing, see Specify Allowed Subclasses.

Example: classdef (AllowedSubclasses = {?ClassName1,?ClassName2}) ...

Data Types: logical

Can class be subclassed, returned as a logical value. If Sealed is true, this class cannot be subclassed.

Example: classdef (Sealed = true) ...

Data Types: logical

Direct superclasses of this class, returned as an array of meta.class objects describing each direct superclass from which this class derives. For more information subclassing, see Subclass Definition.

Example: classdef MyClass < MySuperclass & MyMixin

Data Types: meta.class


expand all


Event NameTriggerEvent DataEvent Attributes

This event occurs every time an instance of the class described by the meta.class is created.

The event occurs immediately after all constructor functions finish executing.


NotifyAccess: private

ListenAccess: public


This event occurs every time an instance of the class described by the meta.class is destroyed.

The event occurs immediately before any destructor functions execute.


NotifyAccess: private

ListenAccess: public


collapse all

Find property attributes using the handle class findobj method and the audioplayer meta.class object. Determine if you can change the SampleRate property on an audioplayer object.

Create an audioplayer object.

player = audioplayer(y,Fs);

Get the meta.class object for the audioplayer object.

mc = metaclass(player);

Get the object for the SampleRate property.

mp = findobj(mc.PropertyList,'Name','SampleRate');

Use the object to determine if the SampleRate property can be modified. If SetAccess is public, set the SampleRate property.

if strcmp(mp.SetAccess,'public')
   player.SampleRate = 7200;
Introduced in R2008a