Main Content

Methods

Method syntax, attributes, and purpose

Methods are the operations defined by a class. Methods can overload MATLAB® functions to perform the operations on objects of the class. MATLAB determines which method or function to call based on the dominant argument. Class constructor methods create objects of the class and must follow specific rules.

Functions

methodsClass method names
ismethodDetermine if object has specified method

Classes

matlab.metadata.MethodDescribe MATLAB class method

Topics

Define and Invoke Methods

Method Types

  • Ordinary Methods
    Define ordinary methods within the class definition file using method blocks.
  • Class Constructor Methods
    The class constructor is a special method that creates instances of the class.
  • Static Methods
    Static methods do not require an object of the class as an input argument.

Methods That Overload Functions