Methoden
Methodensyntax, Attribute und Zweck
Methoden sind die über eine Klasse definierten Operationen. Methoden können MATLAB®-Funktionen überladen, um Operationen auf Objekten der Klasse auszuführen. MATLAB legt fest, welche Methode oder Funktion basierend auf dem dominanten Argument aufzurufen ist. Die Klassenkonstrukteur-Methode erstellt Objekte der Klasse und muss spezifische Regeln befolgen.
Klassen
matlab.metadata.Method | Describe MATLAB class method |
Themen
Methodennutzung
- Methods in Class Design
Different kinds of methods perform specific tasks in MATLAB classes. - Method Syntax
Define class methods, including attributes and argument validation. - Method Invocation
Invoke class methods using dot or function syntaxes. - Method Access List
Specify a list of classes that can access a class method. - Methods in Separate Files
Define class methods in separate files for convenience and efficiency.
Methodentypen
- Method Attributes
Method attributes control the behavior of methods. - 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.
Methoden mit Funktionsüberladung (Ad-hoc-Polymorphie)
- Overload Functions in Class Definitions
By overloading MATLAB functions for your class, objects of the class can support MATLAB operations. - Class Support for Array-Creation Functions
Add support for array-creation functions without overloading these functions in your class. - Objects in Conditional Statements
Enable the use of objects in conditional statements by defining relational operators for the class of the object.