Main Content

isUnderlyingType

Determine whether input has specified underlying data type

Since R2020b

Description

tf = isUnderlyingType(X,typename) returns logical 1 (true) if the underlying data type of X is equal to typename, as returned by underlyingType(X). Otherwise, the result is logical 0 (false).

example

Examples

collapse all

Use isUnderlyingType to query the data type of several variables.

Create a numeric variable that has a data type of single and then test whether the underlying data type is also single.

x = single(5);
tf = isUnderlyingType(x,"single")
tf =

  logical

   1

The result is true because underlyingType(x) returns 'single'.

Next, create a table with two variables and then determine whether the underlying data type is string.

x = table([1; 2; 3],["a"; "b"; "c"]);
tf = isUnderlyingType(x,"string")
tf =

  logical

   0

In this case, the result is false because underlyingType(x) returns 'table'.

Now, create a distributed array (requires Parallel Computing Toolbox™) and then determine whether the underlying data type is double.

x = distributed(1:10);
tf = isUnderlyingType(x,"double")
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 6).

tf =

  logical

   1

The result is true because underlyingType(x) returns 'double'. In this case, class(x) returns the name of the class for the variable, while underlyingType(x) returns the name of the data type for the underlying data.

Input Arguments

collapse all

Input array or object, specified as a variable or expression.

Example: isUnderlyingType(gpuArray(double(1)),"single") tests whether the input gpuArray contains underlying data of type single.

Name of data type to test, specified as a character vector or string scalar.

Example: isUnderlyingType(X,"double") tests whether X has underlying type double.

Data Types: char | string

Extended Capabilities

Version History

Introduced in R2020b