Call a method inherited from class double that operates on the data, such as sum. sum
returns a double and, therefore, uses the display method of class double:
sum(sc)
ans =
55
Index sc like an array of doubles. The returned value is the class of the subclass:
a = sc(2:4)
a =
1x3 DocSimpleDouble:
double data:
2 3 4
Indexed assignment works the same as the built-in class. The returned value is the class
of the subclass:
sc(1:5) = 5:-1:1
sc =
1x10 DocSimpleDouble:
double data:
5 4 3 2 1 6 7 8 9 10
Calling a method that modifies the order of the data elements operates on the data, but
returns an object of the subclass:
sc = DocSimpleDouble(1:10);
sc(1:5) = 5:-1:1;
a = sort(sc)
a =
1x10 DocSimpleDouble:
double data:
1 2 3 4 5 6 7 8 9 10
Built-In Data Value Methods
When you call a built-in data value method on a subclass object, MATLAB uses the
superclass part of the subclass object as inputs to the method. The value returned is same
class as the built-in class. For example:
Behavior of Inherited Built-In Methods