MATLAB Object-Oriented Programming

(Joyce) #1
Numeric values (floating-point and integer values):

isa(a,'numeric')

ans =
1

isa Returns True for Subclasses

isa returns true for classes derived from the specified class. For example, the SubInt
class derives from the built-in type int16:

classdef SubInt < int16
methods
function obj = SubInt(data)
if nargin == 0
data = 0;
end
obj = obj@int16(data);
end
end
end

By definition, an instance of the SubInt class is also an instance of the int16 class:

aInt = SubInt;
isa(aInt,'int16')

ans =
1

Using the integer category also returns true:

isa(aInt,'integer')

ans =
1

Test for Specific Types


The class function returns the name of the most derived class of an object:

class(aInt)

12 How to Build on Other Classes

Free download pdf