isUnderlyingType — Test whether a value has a specified underlying MATLAB data type.

isUnderlyingType(X, typename) returns true when underlyingType(X) equals typename. The type name must be a string scalar or a character row vector.

Syntax

tf = isUnderlyingType(X, typename)

Inputs

NameTypeRequiredDefaultDescription
XAnyYesInput array or object to inspect.
typenameStringScalarYesUnderlying data type name to test.

Returns

NameTypeDescription
tfLogicalArrayTrue when X has the requested underlying type.

Errors

IdentifierWhenMessage
RunMat:isUnderlyingType:TypeNameInvalidSecond argument is not a string scalar or row character vector.isUnderlyingType: TYPENAME must be a string scalar or character vector

How isUnderlyingType works

  • The predicate compares against the same canonical type names returned by underlyingType, such as "double", "single", "logical", "char", "string", "cell", and object class names.
  • The typename input accepts a string scalar or a character row vector. Multi-element string arrays, multi-row character arrays, and non-text values throw a structured argument error.
  • gpuArray inputs are checked from handle metadata. Exact class-name metadata is preferred for uploaded integer and floating-point device arrays; provider precision is used as a fallback for handles that only expose F32/F64.
  • isUnderlyingType(X, typename) compares the requested type name exactly after trimming surrounding whitespace.

Does RunMat run isUnderlyingType on the GPU?

No provider hook is required. RunMat maps gpuArray class-name, logical, and precision metadata to the same names returned by underlyingType and compares that name exactly with the requested type.

GPU memory and residency

isUnderlyingType is metadata-only for gpuArray inputs. It returns a host logical scalar and preserves provider residency for the inspected buffer.

Examples

Check a single-precision array

A = single([1 2 3]);
tf = isUnderlyingType(A, "single")

Expected output:

tf = logical(1)

Reject a mismatched underlying type

tf = isUnderlyingType(true, "double")

Expected output:

tf = logical(0)

Check gpuArray element type without gathering

G = gpuArray(single([1 2 3]));
tf = isUnderlyingType(G, "single")

Expected output:

tf = logical(1)

Using isUnderlyingType with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how isUnderlyingType changes the result.

Run a small isUnderlyingType example, explain the result, then change one input and compare the output.

FAQ

Is this the same as isa(X, typename)?

No. isa tests the class or category of the value itself. isUnderlyingType tests the data type returned by underlyingType, which differs for gpuArray values.

What text forms are accepted for typename?

Use a string scalar such as "double" or a character row vector such as 'double'. Non-scalar string arrays and multi-row character arrays are rejected.

Will this gather gpuArray data?

No. The predicate reads class-name, logical, and precision metadata from the gpuArray handle and returns a host logical scalar.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how isUnderlyingType is executed, line by line, in Rust.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.