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
    • allfinite
    • iscell
    • iscellstr
    • isfinite
    • isgpuarray
    • isinf
    • islogical
    • isnan
    • isnumeric
    • isreal
    • issparse
    • isstruct

isnan — Determine which array elements are NaN.

isnan returns a same-shaped logical mask that identifies NaN components in real and complex values.

Syntax

tf = isnan(A)

Inputs

A
Type
Any
Required
Yes
Description
Numeric, logical, character, or string input to classify element by element.
NameTypeRequiredDefaultDescription
AAnyYes—Numeric, logical, character, or string input to classify element by element.

Returns

tf
Type
LogicalArray
Description
Same-shaped logical mask that is true where either numeric component is NaN.
NameTypeDescription
tfLogicalArraySame-shaped logical mask that is true where either numeric component is NaN.

Errors

RunMat:isnan:InvalidInput
When
Input is sparse or is not numeric, logical, character, or string data.
Message
isnan: invalid input
RunMat:isnan:InternalError
When
Internal mask construction, provider execution, or residency restoration fails.
Message
isnan: internal error
RunMat:isnan:TooManyOutputs
When
More than one output is requested.
Message
isnan: too many output arguments
IdentifierWhenMessage
RunMat:isnan:InvalidInputInput is sparse or is not numeric, logical, character, or string data.isnan: invalid input
RunMat:isnan:InternalErrorInternal mask construction, provider execution, or residency restoration fails.isnan: internal error
RunMat:isnan:TooManyOutputsMore than one output is requested.isnan: too many output arguments

Values and classes

isnan(A) returns true where an element contains an IEEE NaN. A complex element is true when either its real or imaginary component is NaN.

Fixed-width integers, logical values, and character code points cannot contain NaN and therefore produce false masks. String scalars return false and string arrays produce same-shaped false masks. Sparse and unrelated container values are rejected.

Shape, residency, and fusion

The result is a logical scalar for scalar input and a same-shaped logical array for nonscalar or empty input.

Resident floating input uses the exact owner's logical_isnan operation. A typed unsupported result may gather once and restore the logical output to that owner. Integer input needs no payload download because its class determines an all-false result. Compatible elementwise expressions may fuse.

Examples

Classify a NaN scalar

tf = isnan(NaN)

Expected output:

tf = true

Build a NaN mask

A = [1 NaN 2; 3 4 NaN];
tf = isnan(A)

Expected output:

tf = [false true false; false false true]

Classify either complex component

Z = complex([1 NaN 3], [2 0 NaN]);
tf = isnan(Z)

Expected output:

tf = [false true true]

Classify character code points

tf = isnan(['R' 'u' 'n'])

Expected output:

tf = [false false false]

Classify fixed-width integers exactly

A = [uint64(0), uint64(9007199254740992) + uint64(1), intmax('uint64')];
tf = isnan(A)

Expected output:

tf = [false false false]

Keep the NaN mask resident

A = gpuArray(single([1 NaN 3]));
gtf = isnan(A);
tf = gather(gtf)

Expected output:

gtf remains a gpuArray and tf = [false true false]

Using isnan with coding agents

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

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

FAQ

Does isnan modify its input?⌄

No. It returns a new logical mask and leaves host- or provider-resident input unchanged.

How are complex values classified?⌄

An element is true when either its real or imaginary component is NaN. Infinity alone does not count as NaN.

How are logical, character, and string values classified?⌄

These classes cannot contain NaN, so they produce false values with the corresponding shape.

How should NaN values be filtered?⌄

Use the logical result as an index or combine it with any along the dimension whose rows or columns should be selected.

Does gpuArray input use a provider operation?⌄

Yes. RunMat asks the exact owner for logical_isnan; only a typed unsupported result enters the class-preserving fallback path.

What happens for an empty array?⌄

The result is an empty logical array with the same dimensions as the input.

How do isnan, isinf, and isfinite differ?⌄

isnan identifies NaN, isinf identifies positive or negative infinity, and isfinite identifies values that are neither. For an ordinary real floating value, exactly one predicate is true.

Can isnan participate in a fused expression?⌄

Yes. The placement and fusion planner can combine compatible elementwise work when the selected provider supports the complete region.

Related Logical functions

Tests

allfinite · iscell · iscellstr · isfinite · isgpuarray · isinf · islogical · isnumeric · isreal · issparse · isstruct

Bit

and · not · or · xor

Rel

eq · ge · gt · isequal · isequaln · le · lt · ne

Logical

logical

Source you can read

Every RunMat function's source is public. Read exactly how isnan is executed, line by line, in Rust.

  • View the source for isnan 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
  • Errors
  • Values and classes
  • Shape, residency, and fusion
  • Examples
  • Classify a NaN scalar
  • Build a NaN mask
  • Classify either complex component
  • Classify character code points
  • Classify fixed-width integers exactly
  • Keep the NaN mask resident
  • Using isnan with coding agents
  • FAQ
  • Related Logical functions
  • Tests
  • Bit
  • Rel
  • Logical
  • Source you can read
  • About RunMat