RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

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.

/
See all docs
Builtin Reference
    • addlistener
    • addParameter
    • addprop
    • assignin
    • builtin
    • cancel
    • class
    • clear
    • clearAllMemoizedCaches
    • clearCache
    • clearvars
    • dbclear
    • dbstack
    • dbstatus
    • dbtype
    • eval
    • evalc
    • evalin
    • feval
    • findprop
    • func2str
    • functions
    • get.p
    • getcallinfo
    • getmethod
    • inputname
    • inputParser
    • isa
    • ischar
    • isdeployed
    • iskeyword
    • ismethod
    • isobject
    • isstring
    • isUnderlyingType
    • isvalid
    • keyboard
    • loadobj
    • localfunctions
    • matlab.metadata.DynamicProperty.delete
    • memoize
    • metaclass
    • mfilename
    • mislocked
    • mlock
    • munlock
    • namelengthmax
    • narginchk
    • nargoutchk
    • new_object
    • notify
    • numArgumentsFromSubscript
    • onCleanup
    • parse
    • saveobj
    • set.p
    • stats
    • str2func
    • subsasgn
    • subsref
    • 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

A
Type
Any
Required
Yes
Description
Input value to inspect without materializing its payload.
NameTypeRequiredDefaultDescription
AAnyYes—Input value to inspect without materializing its payload.

Returns

name
Type
StringScalar
Description
Class name for the input value.
NameTypeDescription
nameStringScalarClass name for the input value.

Behavior

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".

GPU and residency

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.

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.

No GPU kernels run. Explicit user-visible gpuArray values report the wrapper class; internal automatic residency reports the underlying host class. Both paths use metadata without gathering data.

Legacy examples and displayed results

Check the class of a numeric scalar

c = class(42)

Expected display: c = "double"

Inspect the class of a string array

names = ["Ada", "Grace", "Edsger"];

class_name = class(names)

Expected display: class_name = "string"

Determine whether a cell array stays typed as a cell

cells = {1, "two", 3};

cell_class = class(cells)

Expected display: cell_class = "cell"

Detect the class of gpuArray data without gathering

G = gpuArray(rand(4));

g_class = class(G)

Expected display: g_class = "gpuArray"

Report the class name of a custom object

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

point_class = class(P)

Expected display: point_class = "Point"

Example

Inspect a type with an assertion

c = class(42)

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?⌄

RunMat currently returns a string scalar. This preserves the existing runtime carrier; character-row parity with MATLAB remains a separate compatibility issue. Convert the result with char(class(...)) when a character row is needed.

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

addlistener · addParameter · addprop · assignin · builtin · cancel · clear · clearAllMemoizedCaches · clearCache · clearvars · dbclear · dbstack · dbstatus · dbtype · eval · evalc · evalin · feval · findprop · func2str · functions · get.p · getcallinfo · getmethod · inputname · inputParser · isa · ischar · isdeployed · iskeyword · ismethod · isobject · isstring · isUnderlyingType · isvalid · keyboard · loadobj · localfunctions · matlab.metadata.DynamicProperty.delete · memoize · metaclass · mfilename · mislocked · mlock · munlock · namelengthmax · narginchk · nargoutchk · new_object · notify · numArgumentsFromSubscript · onCleanup · parse · saveobj · set.p · stats · str2func · subsasgn · subsref · superclasses · underlyingType · verLessThan · version · which · who · whos

Source you can read

Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Behavior
  • GPU and residency
  • Legacy examples and displayed results
  • Example
  • Inspect a type with an assertion
  • Using class with coding agents
  • FAQ
  • Related Introspection functions
  • Source you can read
  • About RunMat