This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the 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.


class Determine class of object
isobject Determine if input is MATLAB object
enumeration Display class enumeration members and names
events Event names
methods Class method names
properties Class 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.

Was this topic helpful?