MATLAB Object-Oriented Programming

(Joyce) #1

numel(sd)


ans =


10


Object arrays return the size of the superclass arrays:


size([sd;sd])


ans =


2 10


numel([sd;sd])


ans =


20


The SimpleDouble class inherits the indexing behavior of the double class:


sdsub = sd(7:end);
size(sdsub)


ans =


1 4


Classes Not Derived from Built-In Classes


Consider a simple value class. This class does not inherit the array-like behaviors of the
double class. For example:


classdef VerySimpleClass
properties
Value
end
end


Create an object and assign a 10-element array to the Value property:


vs = VerySimpleClass;
vs.Value = 1:10;
size(vs)


Use of size and numel with Classes
Free download pdf