Describe method of MATLAB class


The meta.method class provides information about the methods of MATLAB® classes. The read/write properties of the meta.method class correspond to method attributes and are specified only from within class definitions.

You can query the read-only properties of the meta.method object to obtain information that is specified syntactically by the class (for example, to obtain the name of the class defining a method).

You cannot instantiate a meta.method object directly. Obtain a meta.method object from the meta.class MethodList property, which contains an array of meta.method objects, one for each class method. For example, replace ClassName with the name of the class whose methods you want to query:

mco = ?ClassName;
mlist = mco.MethodList;
mlist(1).Name; % name of first method in the list

Use the metaclass function to obtain a meta.class object from a class instance:

mco = metaclass(obj);



If true, the method has no implementation. The method has a syntax line that can include arguments, which subclasses use when implementing the method.

  • Subclasses are not required to define the same number of input and output arguments.

  • The method can have comments after the function line

  • Does not contain function or end keywords, only the function syntax (e.g., [a,b] = myMethod(x,y))

Access attribute, default = public

Determines what code can call this method.

  • public — unrestricted access

  • protected — access from methods in class or subclasses

  • private — access by class methods only (not from subclasses)

  • List classes that have access to this method. Specify classes as meta.class objects in the form:

    • A single meta.class object

    • A cell array of meta.class objects. An empty cell array, {}, is the same as private access.

DefiningClassThe meta.class object representing the class that defines this method.
Description read-only

Currently not used.

DetailedDescription read-only

Currently not used.

Hidden attribute, default = false

When false, the method name shows in the list of methods displayed using the methods or methodsview commands. If set to true, the method name is not included in these listings.


Character vector or cell array containing the names of the input arguments used in the function signature.

Name read-only

Name of the method.


Character vector or cell array containing the names of the output arguments used in the function signature.

Sealed attribute, default = falseIf true, the method cannot be redefined in a subclass. Attempting to define a method with the same name in a subclass causes an error.
Static attribute, default = false

Set to true to define a method that does not depend on an object of the class and does not require an object argument. Call static methods using the class name in place of the object:


Or with an instance of the class, like any method:


See Static Methods