MATLAB class definitions comprise code blocks that define properties, methods, and events. Each block can declare attributes that apply to all properties, methods, or events defined in that particular block. Attributes also can apply to the class itself.
class | Class of object |
isobject | Determine if input is MATLAB object |
enumeration | Class enumeration members and names |
events | Event names |
methods | Class method names |
properties | Class property names |
superclasses | Names of superclasses |
Define class components in code blocks that apply attributes to all class members in that block.
Organize classes in path folders or distribute the class definition among multiple files in a class @ folder.
The classdef
block contains the class definition including all class member blocks.
Define properties in a properties
block that specifies the property name, and optional type, default value, and attributes.
Define Class Methods and Functions
Define methods in a methods
block that specifies attributes for all methods defined in that block.
Specify attributes in the property
, methods
, or events
block. Attributes apply to all members defined in that block.
Define event names in an events
block. Only handle classes support events.
This example of a MATLAB class definition shows syntax and programming techniques used in typical classes.