方法
方法的语法、属性和用途
方法是由类定义的操作。方法可以重载 MATLAB® 函数以对类的对象执行操作。MATLAB 根据主导参数来确定要调用的方法或函数。类构造函数方法创建类的对象,并且必须符合特定的规则。
类
meta.method | 描述 MATLAB 类方法 |
主题
方法使用
- 类设计中的方法
不同种类的方法在 MATLAB 类中执行不同的特定任务。 - 方法语法
定义类方法,包括特性和参量验证。 - 方法调用
使用圆点语法或函数语法调用类方法。 - Method Access List
Specify a list of classes that can access a class method. - 在单独文件中定义方法
为了方便和高效,可以在单独的文件中定义类方法。
方法类型
- 方法特性
方法特性用来控制方法的行为。 - Ordinary Methods
Define ordinary methods within the class definition file using method blocks. - 类构造函数方法
类构造函数是一个创建类实例的特殊方法。 - 静态方法
静态方法不需要类的对象作为输入参量。
重载函数的方法
- 在类定义中重载函数
通过为您的类重载 MATLAB 函数,该类的对象可以支持 MATLAB 运算。 - 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.