23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2 Data Types<br />

<strong>MATLAB</strong> Classes<br />

All <strong>MATLAB</strong> data types are implemented as object-oriented classes. You<br />

can add data types of your own to your <strong>MATLAB</strong> environment by creating<br />

additional classes. These user-defined classes define the structure of your new<br />

data type, and the M-file functions, or methods, that you write for each class<br />

define the behavior for that data type.<br />

These methods can also define the way various <strong>MATLAB</strong> operators, including<br />

arithmetic operations, subscript referencing, and concatenation, apply to the<br />

new data types. For example, a class called polynomial might redefine the<br />

addition operator (+) so that it correctly performs the operation of addition<br />

on polynomials.<br />

With <strong>MATLAB</strong> classes you can<br />

• Create methods that override existing <strong>MATLAB</strong> functionality<br />

• Restrict the operations that are allowed on an object of a class<br />

• Enforce common behavior among related classes by inheriting from the<br />

same parent class<br />

• Significantly increase the reuse of your code<br />

Read more about <strong>MATLAB</strong> classes in Chapter 9, “Classes and Objects”.<br />

2-118

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!