MATLAB Object-Oriented Programming

(Joyce) #1

This class implements the following subscripted indexing expressions for reference and
assignment.



  • obj.DataString — access the DataString property.

  • obj.Data, obj.Data(ind) — access the data using a property-style reference.
    Reference returns values of type double.

  • obj(ind) — access the numeric data (same as obj.Data(ind)). Reference returns
    values of type ExtendDouble.


The class subsref method enables you to use ExtendDouble objects like numeric
arrays to reference the numeric data:


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


ans =


One to ten
10 9 8 7 6 5 4 3 2 1


Access the numeric data of the ExtendDouble using property-style indexing with the
arbitrarily chosen name Data:


ed.Data(10:-1:1)


ans =


One to ten
10 9 8 7 6 5 4 3 2 1


Access the DataString property:


ed.DataString


ans =


One to ten


Subscripted assignment implements similar syntax in the class subsasgn method.


ed = ExtendDouble(1:10,'One to ten');
ed(11:13) = [11,12,13];
ed.DataString = 'one to thirteen';
ed


Subclasses of Built-In Types with Properties
Free download pdf