RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • addprop
    • assignin
    • class
    • clear
    • clearAllMemoizedCaches
    • clearCache
    • clearvars
    • dbclear
    • dbstack
    • dbstatus
    • dbtype
    • evalc
    • feval
    • findprop
    • getcallinfo
    • inputParser
    • isa
    • ischar
    • isdeployed
    • iskeyword
    • ismethod
    • isobject
    • isstring
    • isUnderlyingType
    • keyboard
    • matlab.metadata.DynamicProperty.delete
    • memoize
    • metaclass
    • mislocked
    • mlock
    • munlock
    • namelengthmax
    • narginchk
    • nargoutchk
    • notify
    • onCleanup
    • stats
    • str2func
    • superclasses
    • underlyingType
    • verLessThan
    • version
    • which
    • who
    • whos

class — Return class names for values in MATLAB and RunMat.

class(x) returns the class name for value x as a string scalar. Use it for diagnostics, branching, and display logic with MATLAB- and RunMat-compatible class labels.

Syntax

name = class(A)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—Input value to inspect.

Returns

NameTypeDescription
nameStringScalarClass name for the input value.

How class works

  • Real or complex double-precision inputs (including empty numeric arrays) report "double". Integer scalars or tensors report their narrow class such as "int16" or "uint8".
  • Logical scalars and arrays report "logical". Character arrays return "char", while string scalars or arrays return "string".
  • Cell arrays, structs, and user-defined classdef objects report "cell", "struct", or the class name that defined the object.
  • Function handles and anonymous closures both report "function_handle". Listeners return "event.listener".
  • Explicit user-visible gpuArray values report "gpuArray" without gathering data. Internal automatic residency remains transparent and reports the underlying host class from coherent metadata.
  • Handle objects, including deleted handles, return the class name that introduced the handle. Metadata-only values such as classref("Point") report "meta.class".

Does RunMat run class on the GPU?

class is an introspection-only builtin. When the input resides on the GPU, RunMat reads the residency metadata, returns the class name immediately, and leaves the data in place. No kernels are launched and no buffers are copied back to the CPU, so providers do not need to expose any hooks.

GPU memory and residency

You do not need to call gpuArray purely to query a value’s class. The auto-offload planner keeps tensors on the GPU whenever profitable, and class simply returns the residency-aware class name without altering where the data lives. Explicit gpuArray and gather calls remain available for compatibility with MATLAB code that manages residency manually.

Examples

Check the class of a numeric scalar

c = class(42)

Expected output:

c = "double"

Inspect the class of a string array

names = ["Ada", "Grace", "Edsger"];
class_name = class(names)

Expected output:

class_name = "string"

Determine whether a cell array stays typed as a cell

cells = {1, "two", 3};
cell_class = class(cells)

Expected output:

cell_class = "cell"

Detect the class of gpuArray data without gathering

G = gpuArray(rand(4));
g_class = class(G)

Expected output:

g_class = "gpuArray"

Report the class name of a custom object

P = classref("Point").origin();
point_class = class(P)

Expected output:

point_class = "Point"

Using class with coding agents

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

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

FAQ

Does class return a string or a character array?⌄

class returns a string scalar, matching modern MATLAB behaviour. Convert the result with char(class(...)) if you need a legacy character row vector.

How do I check whether a value is numeric?⌄

Use isa(x, "numeric") to handle floats, complex numbers, and integers. class reports the concrete class ("double", "int32", and so on).

Will class gather gpuArray inputs?⌄

No. RunMat inspects metadata without copying the buffer. Explicit gpuArray values return "gpuArray"; internally auto-resident values return their underlying host class.

What does class return for handle objects?⌄

class returns the object’s defining class name (for example "MyHandleClass"). Use isa(h, "handle") to test for handle semantics.

What happens if I pass a struct or cell array?⌄

Structs return "struct" and cell arrays return "cell", matching MATLAB.

What is the class of function handles?⌄

Both named function handles and anonymous closures report "function_handle".

Can I distinguish string and char arrays?⌄

Yes. class("hello") yields "string" while class('hello') yields "char".

What about metadata objects such as classref?⌄

Calling class(classref("Point")) returns "meta.class". Use the returned meta-class object to inspect properties or superclasses.

Related Introspection functions

addprop · assignin · clear · clearAllMemoizedCaches · clearCache · clearvars · dbclear · dbstack · dbstatus · dbtype · evalc · feval · findprop · getcallinfo · inputParser · isa · ischar · isdeployed · iskeyword · ismethod · isobject · isstring · isUnderlyingType · keyboard · matlab.metadata.DynamicProperty.delete · memoize · metaclass · mislocked · mlock · munlock · namelengthmax · narginchk · nargoutchk · notify · onCleanup · stats · str2func · superclasses · underlyingType · verLessThan · version · which · who · whos

Open-source implementation

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

  • View the source for class 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.

Getting started · Benchmarks · Pricing

Download RunMat

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

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • How class works
  • Does RunMat run class on the GPU?
  • GPU memory and residency
  • Examples
  • Check the class of a numeric scalar
  • Inspect the class of a string array
  • Determine whether a cell array stays typed as a cell
  • Detect the class of gpuArray data without gathering
  • Report the class name of a custom object
  • Using class with coding agents
  • FAQ
  • Related Introspection functions
  • Open-source implementation
  • About RunMat