isUnderlyingType
Determine whether input has specified underlying data type
Description
Examples
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
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
Usage notes and limitations:
Does not support input argument
Xthat is ofdlarray(Deep Learning Toolbox) type.
Refer to the usage notes and limitations in the C/C++ Code Generation section. The same usage notes and limitations apply to GPU code generation.
The isUnderlyingType function fully supports
thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
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).
The isUnderlyingType 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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)