MATLAB Object-Oriented Programming

(Joyce) #1

The increased flexibility of the implementation of indexed reference in the
ExtendDouble class.


Concatenation of ExtendDouble Objects


Create these two objects:


ed1 = ExtendDouble([1:10],'One to ten');
ed2 = ExtendDouble([10:-1:1],'Ten to one');


Concatenate these objects along the horizontal dimension:


hcat = [ed1,ed2]


hcat =


'One to ten' 'Ten to one'


Columns 1 through 13


1 2 3 4 5 6 7 8 9 10 10 9 8


Columns 14 through 20


7 6 5 4 3 2 1


whos


Name Size Bytes Class Attributes


ed1 1x10 204 ExtendDouble
ed2 1x10 204 ExtendDouble
hcat 1x20 528 ExtendDouble


Vertical concatenation works in a similar way:


vcat = [ed1;ed2]


vcat =


'One to ten' 'Ten to one'


1 2 3 4 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1


Both horzcat and vertcat return a new object of the same class as the subclass.


Subclasses of Built-In Types with Properties
Free download pdf