Class Syntax and File Organization
Class block syntax, attributes, and organization in files and
folders
Use classdef to define class blocks and specify class
attributes. Organize class files and folders using namespaces. For a basic
example of a class that demonstrates several object-oriented programming
techniques in MATLAB®, see Creating a Simple Class.
Functions
Topics
Defining Classes
- User-Defined Classes
MATLAB enables you to define classes to implement object-oriented designs. - Class Attributes
Class attributes enable you to modify the behavior of classes that you define. - Functions Inside Class Definition Files
Just as you can define local functions in a script file or function file, you can also define local functions inside aclassdeffile.
Class and Namespace Folders
- Folders Containing Class Definitions
Define special folders for class files to contain multiple files for class definitions. - Create Namespaces
Use namespaces to organize code. - Import Namespace Members into Functions
Import code from namespaces to simplify references.
Expressions in Classes
- Evaluation of Expressions in Class Definitions
You can use MATLAB expressions to define values for attributes and properties.
Class Precedence
- Class Precedence
Specify a relative precedence among user-defined classes.