Class Files and Folders
In this section...
“Class Definition Files” on page 5-2
“Options for Class Folders” on page 5-2
“Options for Class Files” on page 5-2
“Group Classes with Package Folders” on page 5-3
Class Definition Files
Put class definition code in files that have the .m extension. The name of the file must be
the same as the name of the class followed by the .m extension.
For information on the code that defines a class, see “Class Components” on page 5-5.
Options for Class Folders
There are two ways to create folders that contain class-definition files:
- Path folder — a folder that is on the MATLAB path.
- Class folder — a folder that is in a path folder and is named with the @ character and
the class name. For example:
@MyClass
Class folders are not directly on the MATLAB path. The path folder that contains the class
folder is on the MATLAB path.
Options for Class Files
There are two ways to specify classes with respect to files and folders:
- Create a single, self-contained class definition file in a path folder or a class folder
- Define a class in multiple files, which requires you to use a class folder inside a path
folder
5 Class Definition—Syntax Reference