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
    • argsort
    • intersect
    • ismember
    • ismembertol
    • issorted
    • issortedrows
    • setdiff
    • setxor
    • sort
    • sortrows
    • union
    • unique

ismember — Test membership of elements or rows in MATLAB and RunMat.

ismember(A, B) returns membership flags for elements (or rows) of A in B, with optional first-match indices. Supported ordering and comparison forms are described below.

Syntax

tf = ismember(A, B)
tf = ismember(A, B, option...)
[tf, loc] = ismember(A, B)
[tf, loc] = ismember(A, B, option...)

Inputs

A
Type
Any
Required
Yes
Description
Values or rows to query.
B
Type
Any
Required
Yes
Description
Reference set of values or rows.
option
Type
StringScalar
Required
Variadic
Description
Option tokens: 'rows'.
NameTypeRequiredDefaultDescription
AAnyYes—Values or rows to query.
BAnyYes—Reference set of values or rows.
optionStringScalarVariadic—Option tokens: 'rows'.

Returns

tf
Type
LogicalArray
Description
Membership mask over A.
loc
Type
NumericArray
Description
First-match indices into B for each element/row in A (0 when absent).
NameTypeDescription
tfLogicalArrayMembership mask over A.
locNumericArrayFirst-match indices into B for each element/row in A (0 when absent).

Returned values from ismember depend on how many outputs the caller requests.

Errors

RunMat:ismember:LegacyOptionUnsupported
When
Legacy compatibility options are requested.
Message
ismember: the 'legacy' behaviour is not supported
RunMat:ismember:UnknownOption
When
An unsupported option token is provided.
Message
ismember: unrecognised option
RunMat:ismember:RowsColumnMismatch
When
'rows' mode is used and column counts differ.
Message
ismember: inputs must have the same number of columns when using 'rows'
IdentifierWhenMessage
RunMat:ismember:LegacyOptionUnsupportedLegacy compatibility options are requested.ismember: the 'legacy' behaviour is not supported
RunMat:ismember:UnknownOptionAn unsupported option token is provided.ismember: unrecognised option
RunMat:ismember:RowsColumnMismatch'rows' mode is used and column counts differ.ismember: inputs must have the same number of columns when using 'rows'
RunMat:ismember:UnsupportedInputTypeInput classes or execution residency are unsupported.ismember: unsupported input type
RunMat:ismember:NumericClassMismatchNumeric inputs have incompatible nondouble classes.ismember: numeric inputs must have the same class, except double may be combined with one nondouble class
RunMat:ismember:InvalidArgumentOption arguments are not string-like where required.ismember: expected string option arguments
RunMat:ismember:InternalInternal conversion/allocation/provider decode fails.ismember: internal operation failed

Behavior

The first output tf has the same shape as A (or size(A,1) × 1 when using 'rows').

The optional second output loc contains one-based indices into B, with 0 for values that are not found.

Duplicate values in A return the index of the first occurrence in B every time they match.

NaN values do not match any value, including NaNs in B; their mask is false and location is zero.

Character arrays follow column-major linear indexing, mirroring MATLAB.

The 'rows' option compares complete rows; inputs must agree on the number of columns.

Legacy flags ('legacy', 'R2012a') are deliberately unsupported in RunMat.

Types, placement and limitations

The logical mask and double first-location output have the shape of A, or one row per record in rows mode. NaNs never match, even another NaN. Complex values or rows containing any NaN component also return false and location zero. Resident outputs are restored to the first resident input owner.

Resident execution

These operations are eager fusion boundaries, not elementwise kernels or reductions, and do not broadcast. Provider availability does not imply a device-native sorting or set kernel: current providers may stage host work. An unsupported input can use exact host fallback before provider work starts. Errors after an attempt, including cancellation, are returned without repeating the operation on the host. Supported resident outputs return to their owning provider; predicates and all-indices cells have the host placement described above. Distributed execution is not supported.

Examples

Checking membership of numeric vectors

A = [5 7 2 7];
B = [7 9 5];
[tf, loc] = ismember(A, B)

Expected output:

tf =
     1     1     0     1
loc =
     3     1     0     1

Finding row membership in a matrix

A = [1 2; 3 4; 1 2];
B = [3 4; 5 6; 1 2];
[tf, loc] = ismember(A, B, 'rows')

Expected output:

tf =
     1
     1
     1
loc =
     3
     1
     3

Locating values and retrieving the index

values = [10 20 30];
set = [30 10 40];
[tf, loc] = ismember(values, set)

Expected output:

tf =
     1     0     1
loc =
     2     0     1

Testing characters against a set

chars = ['r','u'; 'n','m'];
set = ['m','a'; 'r','u'];
[tf, loc] = ismember(chars, set)

Expected output:

tf = [1 1; 0 1]; loc = [2 4; 0 1]

Working with string arrays

A = ["apple" "pear" "banana"];
B = ["pear" "orange" "apple"];
[tf, loc] = ismember(A, B)

Expected output:

tf =
  1×3 logical array
   1   1   0
loc =
  1×3 double
   3   1   0

Using ismember with gpuArray inputs

G = gpuArray([1 4 2 4]);
H = gpuArray([4 5]);
[tf, loc] = ismember(G, H)

Expected output:

tf =
     0     1     0     1
loc =
     0     1     0     1

Return false and zero for NaN membership

[tf,loc] = ismember([NaN 1 NaN],[NaN 1]); [rows,positions] = ismember([1 NaN;2 3],[1 NaN;2 3],'rows');

Using ismember with coding agents

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

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

FAQ

Does ismember treat NaN values as equal?⌄

The logical mask and double first-location output have the shape of A, or one row per record in rows mode. NaNs never match, even another NaN. Complex values or rows containing any NaN component also return false and location zero. Resident outputs are restored to the first resident input owner.

What happens when an element of A is not found in B?⌄

The corresponding logical entry is false and the index output stores 0, matching MATLAB.

Can I use ismember with string arrays and character arrays?⌄

Yes. String arrays, scalar strings, and character arrays are supported. Mixed string/char inputs should be normalised (for example, convert scalars with string).

How does the 'rows' option change the output shape?⌄

'rows' compares entire rows and returns outputs of size size(A,1) × 1, regardless of how many columns the input matrices contain.

Are the legacy flags supported?⌄

No. RunMat does not implement legacy flag semantics. Passing 'legacy' or 'R2012a' raises an error, just like other set builtins in RunMat.

Will ismember run on the GPU automatically?⌄

The logical mask and double first-location output have the shape of A, or one row per record in rows mode. NaNs never match, even another NaN. Complex values or rows containing any NaN component also return false and location zero. Resident outputs are restored to the first resident input owner. These operations are eager fusion boundaries, not elementwise kernels or reductions, and do not broadcast. Provider availability does not imply a device-native sorting or set kernel: current providers may stage host work. An unsupported input can use exact host fallback before provider work starts. Errors after an attempt, including cancellation, are returned without repeating the operation on the host. Supported resident outputs return to their owning provider; predicates and all-indices cells have the host placement described above. Distributed execution is not supported.

Related Array functions

Sorting Sets

argsort · intersect · ismembertol · issorted · issortedrows · setdiff · setxor · sort · sortrows · union · unique

Accumulation

accumarray

Shape

blkdiag · cat · circshift · diag · flip · fliplr · flipud · horzcat · ipermute · kron · permute · repelem · repmat · reshape · rot90 · shiftdim · squeeze · toeplitz · tril · triu · vertcat

Creation

colon · createArray · empty · eye · false · full · inf · int16.empty · int32.empty · int64.empty · int8.empty · linspace · logspace · magic · meshgrid · nan · ndgrid · nonzeros · ones · peaks · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · uint16.empty · uint32.empty · uint64.empty · uint8.empty · zeros

Combinatorics

combinations · nchoosek · perms

Binning

discretize

Indexing

find · ind2sub · sub2ind

Grouping

findgroups · groupcounts · grp2idx · splitapply

Introspection

height · iscolumn · isempty · ismatrix · isrow · isscalar · isvector · length · ndims · numel · size · width

Source you can read

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

  • View the source for ismember 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
  • Behavior
  • Types, placement and limitations
  • Resident execution
  • Examples
  • Checking membership of numeric vectors
  • Finding row membership in a matrix
  • Locating values and retrieving the index
  • Testing characters against a set
  • Working with string arrays
  • Using ismember with gpuArray inputs
  • Return false and zero for NaN membership
  • Using ismember with coding agents
  • FAQ
  • Related Array functions
  • Sorting Sets
  • Accumulation
  • Shape
  • Creation
  • Combinatorics
  • Binning
  • Indexing
  • Grouping
  • Introspection
  • Source you can read
  • About RunMat