isUnderlyingType
Description
Examples
Test Underlying Data Type
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
X
— Input array or object
variable | expression
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
.
typename
— Name of data type to test
character vector | string scalar
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
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Does not support input argument
X
that is ofdlarray
(Deep Learning Toolbox) type.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
The isUnderlyingType
function
fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray
(Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced in R2020b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)