This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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.


classDetermine class of object
isobjectDetermine if input is MATLAB object
enumerationClass enumeration members and names
eventsEvent names
methodsClass method names
propertiesClass property names


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.


Define properties in a properties block that specifies the property name, and optional type, default value, and attributes.

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.