| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
| On this page… |
|---|
All classes support the attributes listed in the following table. Attributes enable you to modify the behavior of class. Attribute values apply to the class defined within the classdef block.
Attribute Name | Class | Description |
|---|---|---|
Hidden | logical (default = false) | If true, this class does not appear in the output of MATLAB commands or tools that display class names. |
InferiorClasses | cell (default = {}) | Use this attribute to establish a precedence relationship among classes. Specify a cell array of meta.class objects using the ? operator. The built-in classes double, single, char, logical, int64, uint64, int32, uint32, int16, uint16, int8, uint8, cell, struct, and function_handle are always inferior to user-defined classes and do not show up in this list. |
ConstructOnLoad | logical (default = false) | If true, MATLAB calls the class constructor when loading an object from a MAT-file. Therefore, you must implement the constructor so it can be called with no arguments without producing an error. |
logical (default = false) | If true, this class can not be subclassed. |
Attributes are specified for class members in the classdef, properties, methods, and events definition blocks. The particular attribute setting applies to all members defined within that particular block. This means that, for example, you might use multiple properties definition blocks so you can apply different attribute setting to different properties.
Class attributes are not inherited, so superclass attributes do not affect subclasses.
Specify class attribute values in parentheses, separating each attribute name/attribute value pair with a comma. The attribute list always follows the classdef or class member key word, as shown below:
classdef (attribute-name = expression, ...) ClassName properties (attribute-name = expression, ...) ... end methods (attribute-name = expression, ...) ... end events (attribute-name = expression, ...) ... end end
The term expression in the statements above is used to mean any legal MATLAB expression that evaluates to a single array. The expression is evaluated when the class definition is first needed and the resulting value is treated as a constant.
The MATLAB language evaluates the expression in its own context and cannot reference variables or the class being defined. Attribute expressions can reference static methods and properties of other classes and use the MATLAB path context of the class at the time of definition. This means the expression cannot access variables in the MATLAB workspace, but can access any function and static method or property that is on your path at the time MATLAB evaluates the class definition.
For example, in the following classdef line, the Sealed attribute is set to logical true only if a certain directory is on the MATLAB path.
classdef (Sealed = isdir('myDir'))
![]() | Defining Classes — Syntax | Organizing Classes in Directories | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |