isUnderlyingType

Tests whether a value has a given underlying data type.

Category: Language Fundamentals > Data Types

Syntax

tf = isUnderlyingType(A, typename)

Returns true if the underlying type of A is typename.

Description

For ordinary arrays the underlying type is just the class, so isUnderlyingType(x, 'double') agrees with isa(x, 'double'). The function matters for classes that wrap another type, such as a gpuArray, where it reports the type of the wrapped data. Category names accept any class that belongs to the group.

Input arguments

A
Any value, including objects that wrap a built-in type.
typename
A class name such as 'double' or 'int8', or a category: 'numeric', 'float', 'integer'.

Output arguments

tf
Logical scalar.

Example

Class and category names

isUnderlyingType(int8(1), 'int8')
isUnderlyingType(1, 'single')
isUnderlyingType(1, 'float')
isUnderlyingType(int8(1), 'float')
Output
ans = logical
   1
ans = logical
   0
ans = logical
   1
ans = logical
   0

See also

isa class underlyingType isfloat