This section provides information for people using objects. It does not provide a thorough treatment of object-oriented concepts, but instead focuses on what you need to know to use the objects provided with MATLAB®.
In the simplest sense, objects are special-purpose data structures that have a specific set of operations that you can perform on the data they contain.
You do not need to know how objects implement operations or store data. This fact makes objects modular and easy to pass within application programs. It also isolates your code from changes to the object's design and implementation.
MATLAB uses objects because they are a convenient way to package data. Working with objects in MATLAB is like working with any variables and is often more convenient because objects are optimized for specific purposes. Think of an object as a neatly packaged collection of data that includes functions that operate on the data. The documentation for any particular object describes how to use it.
Objects are organized collections of data and functions that have been designed for specific purposes.
For example, an object might contain time series data that consists of value/time-sample pairs and associated information like units, sample uniformity, and so on. This object can have a set of specific operations designed to perform analysis, such as filtering, interpolating, and plotting.
You can perform the common operations on objects like you can on any variable. For example, you can do the following things with objects:
Create it and assign a variable name so you can reference it again
Assign or reassign data to it (see Accessing Object Data)
Operate on its data (see Calling Object Methods)
Convert it to another class (if this operation is supported by the object's class)
Save it to a MAT-file so you can reload it later (see
Copy it (see Copying Objects)
Clear it from the workspace (
Any object can have restrictions on how you create it, access its data, or what operations you can perform on it. Refer to the documentation for the particular MATLAB object for a description of what you can do with that object.
The MATLAB language uses many specialized objects. For
MException objects capture information
when errors occur,
execute code at a certain time interval, the
enables you to communicate with devices connected to your computer's
serial port, and so on. MATLAB toolboxes often define
objects to manage data and analyses performed by the toolbox.
Objects provide specific functionality that is not necessarily available from general purpose language components.
The MATLAB language enables you to use objects that are defined other in languages. The following objects are different from the MATLAB objects described in this documentation. See the individual sections referenced below for information on using these objects.
Handle Graphics® objects create graphs and GUIs. These objects provide a
to property values. You cannot subclass graphics objects. See Graphics Objects for
Java® classes enable you to access the capabilities of Java classes from MATLAB programs. See Call Java Libraries for more information.
Microsoft® COM objects enable you to integrate these software components into your application. See
Call COM Objects for more information.
Microsoft .NET objects enable you to integrate .NET assemblies into your application. See Call .NET Libraries for more information.
User-defined MATLAB objects created prior to
Version 7.6 used different syntax for class definition (no
and exhibit other differences. See Compatibility with Previous Versions for more information.