MATLAB Object-Oriented Programming

(Joyce) #1

Determine Array Class


In this section...
“Query the Class Name” on page 12-87
“Test for Array Class” on page 12-87
“Test for Specific Types” on page 12-88
“Test for Most Derived Class” on page 12-89

Query the Class Name


To determine the class of an array, use the class function:

a = [2,5,7,11];
class(a)

ans =
double

str = 'Character array';
class(str)

ans =
char

Test for Array Class


The isa function enables you to test for a specific class or a category of numeric class
(numeric, float, integer):

a = [2,5,7,11];
isa(a,'double')

ans =
1

Floating-point values (single and double precision values):

isa(a,'float')

ans =
1

Determine Array Class
Free download pdf