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).
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.
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).
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: United States.
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.