Main Content

Class Syntax Guide

Syntax for defining MATLAB® classes and class components

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.


classClass of object
isobjectDetermine if input is MATLAB object
enumerationClass enumeration members and names
eventsEvent names
methodsClass method names
propertiesClass property names
superclassesNames of superclasses


Class Components

Define class components in code blocks that apply attributes to all class members in that block.

Class Files and Folders

Organize classes in path folders or distribute the class definition among multiple files in a class @ folder.

Classdef Block

The classdef block contains the class definition including all class member blocks.

Class Properties

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.

Attribute Specification

Specify attributes in the property, methods, or events block. Attributes apply to all members defined in that block.

Events and Listeners

Define event names in an events block. Only handle classes support events.

Representative Class Code

This example of a MATLAB class definition shows syntax and programming techniques used in typical classes.