MATLAB Object-Oriented Programming

(Joyce) #1
ed =
One to thirteen'
1 2 3 4 5 6 7 8 9 10 11 12 13

The ExtendDouble inherits converter methods from the double class. For example,
MATLAB calls the char method to perform this assignment statement.

ed(11:13) = ['a','b','c']

ed =
one to thirteen
1 2 3 4 5 6 7 8 9 10 97 98 99

Class of Value Returned by Indexing Expression

The ExtendDouble implements two forms of indexed reference in the subsref method:


  • obj.Data and obj.Data(ind) — Return values of class double

  • obj(ind) — Return values of class ExtendDouble


For example, compare the values returned by these expressions.

ed = ExtendDouble(1:10,'One to ten');
a = ed(1)

a =

One to ten
1

b = ed.Data(1)

b =

1

whos

Name Size Bytes Class Attributes

a 1x1 132 ExtendDouble
b 1x1 8 double
ed 1x10 204 ExtendDouble

12 How to Build on Other Classes

Free download pdf