MATLAB Object-Oriented Programming

(Joyce) #1

50 100 150 200 250 300 350 400 450 500


50


100


150


200


250


Data Operations


Methods that operate on data values, such as arithmetic operators, always return an
object of the built-in type (not of the subclass type). For example, multiplying DocUint8
objects returns a uint8 object:


a = img1.*1.8;
showImage(a);


Undefined function 'showImage' for input arguments of type 'uint8'.


To perform operations of this type, implement a subclass method to override the inherited
method. The times method implements array (element-by-element) multiplication.


Add this method to the DocUint8 class:


Subclasses of Built-In Types Without Properties
Free download pdf