Using ExtendDouble
Create an instance of ExtendDouble and notice that the display is different from the
default:
ed = ExtendDouble(1:10,'One to ten')
ed =
One to ten
1 2 3 4 5 6 7 8 9 10
Inherited Methods
The ExtendDouble class inherits methods from the class double. To see a list of all
public methods defined by the double class, use the methods function:
methods(double.empty)
The sum function continues to operate on the superclass part of the object:
sum(ed)
ans =
55
The sort function works on the superclass part of the object:
sort(ed(10:-1:1))
ans =
1 2 3 4 5 6 7 8 9 10
Arithmetic operators work on the superclass part of the object:
ed.^2
ans =
1 4 9 16 25 36 49 64 81 100
Subscripted Indexing
Because the ExtendDouble class defines a property, the class must implement its own
subsref and subsasgn methods.
12 How to Build on Other Classes