underlyingType — Return the underlying MATLAB data type that determines array behavior.
underlyingType(X) returns the name of the underlying data type that determines how X behaves. For most values this matches class(X). For gpuArray values, class(X) returns "gpuArray" while underlyingType(X) returns the resident element type such as "double", "single", "int32", "uint8", or "logical".
Syntax
typename = underlyingType(X)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
X | Any | Yes | — | Input array or object to inspect. |
Returns
| Name | Type | Description |
|---|---|---|
typename | StringScalar | Name of the underlying MATLAB data type. |
How underlyingType works
- Double scalars, complex values, sparse arrays, and double tensors report
"double". - Single-precision tensors report
"single"; integer values report their concrete integer class such as"int32"or"uint16". - Logical scalars and logical arrays report
"logical". Character arrays report"char", and string scalars or arrays report"string". - Cell arrays, structs, objects, handles, listeners, function handles, and metadata values report the same name as
classbecause their behavior is not modeled by a different underlying numeric element type. gpuArrayinputs are metadata-only: RunMat checks handle class-name, logical, and precision metadata and does not copy the device buffer back to the host.
Does RunMat run underlyingType on the GPU?
For gpuArray values uploaded through RunMat, exact class-name metadata is preferred so integer device arrays report names such as "int32" or "uint8". If only provider precision is available, F32 maps to "single" and F64 or unannotated numeric handles map to "double".
GPU memory and residency
underlyingType is metadata-only for gpuArray inputs. It does not launch kernels, copy buffers, or change residency.
Examples
Query a scalar double
t = underlyingType(42)Expected output:
t = "double"Query a single-precision array
A = single([1 2 3]);
t = underlyingType(A)Expected output:
t = "single"Compare class and underlying type for gpuArray data
G = gpuArray(single([1 2 3]));
c = class(G);
t = underlyingType(G)Expected output:
c = "gpuArray"
t = "single"Using underlyingType with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how underlyingType changes the result.
Run a small underlyingType example, explain the result, then change one input and compare the output.
FAQ
How is underlyingType different from class?⌄
For ordinary RunMat values they usually match. For gpuArray values, class reports "gpuArray" while underlyingType reports the underlying element type that controls numeric behavior.
Does underlyingType gather gpuArray data?⌄
No. RunMat reads handle metadata and leaves device buffers resident.
What does it return for objects and containers?⌄
Objects and containers such as cells and structs return the same name as class unless RunMat has a distinct underlying storage type for that value family.
Related Introspection functions
addprop · class · clear · clearAllMemoizedCaches · clearCache · clearvars · dbclear · dbstack · dbstatus · dbtype · evalc · findprop · getcallinfo · inputParser · isa · ischar · isdeployed · iskeyword · ismethod · isobject · isstring · isUnderlyingType · keyboard · matlab.metadata.DynamicProperty.delete · memoize · metaclass · mislocked · mlock · munlock · namelengthmax · onCleanup · stats · superclasses · verLessThan · version · which · who · whos
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how underlyingType is executed, line by line, in Rust.
- View the source for underlyingType in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.