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
    • blanks
    • char
    • compose
    • convertCharsToStrings
    • convertContainedStringsToChars
    • convertStringsToChars
    • genvarname
    • int2str
    • isletter
    • isspace
    • isStringScalar
    • isstrprop
    • mat2str
    • native2unicode
    • newline
    • num2str
    • sprintf
    • sscanf
    • str2double
    • str2num
    • strcmp
    • strcmpi
    • string
    • string.empty
    • strings
    • strlength
    • strncmp
    • strncmpi
    • strtok
    • unicode2native

strcmp — Compare text inputs for exact case-sensitive equality with MATLAB-compatible implicit expansion.

strcmp(a, b) returns logical true when corresponding text values match exactly and false otherwise. It supports MATLAB-compatible string, char, and cellstr-style inputs with implicit expansion.

Syntax

tf = strcmp(A, B)

Inputs

NameTypeRequiredDefaultDescription
AAnyYes—First text input (string/char/cell/string array).
BAnyYes—Second text input (string/char/cell/string array).

Returns

NameTypeDescription
tfLogicalArrayLogical comparison result.

Errors

IdentifierWhenMessage
RunMat:strcmp:InvalidInputAt least one input is not a supported text container.strcmp: text inputs must be string/char/cell/string-array values
RunMat:strcmp:ShapeMismatchInputs are not broadcast-compatible for elementwise comparison.strcmp: input sizes are not broadcast-compatible
RunMat:strcmp:InternalErrorInternal logical result assembly failed.strcmp: internal error

How strcmp works

  • Accepted text types: Works with string scalars/arrays, character vectors or matrices created with char, and cell arrays of character vectors. Mixed combinations are converted automatically, matching MATLAB.
  • Implicit expansion: Scalar inputs expand to the shape of the other operand, producing element-wise comparisons for higher-dimensional arrays.
  • Character arrays: Rows are compared individually. The result is a column vector whose length equals the number of rows in the character array.
  • Cell arrays: Each cell is treated as a text scalar. Scalar cell arrays expand across the other operand before comparison.
  • Missing strings: String elements equal to missing compare unequal to everything, including other missing values.
  • Result form: A single logical scalar is returned for scalar comparisons; otherwise you receive a logical array using column-major MATLAB layout.
  • Case sensitivity: Matching is case-sensitive. Use strcmpi for case-insensitive comparisons.
  • Unsupported datatypes: Following the documented text-comparison rule, integer and other unsupported numeric inputs return scalar logical false; RunMat does not gather or stringify them.

Does RunMat run strcmp on the GPU?

strcmp is a host text comparison sink. Numeric resident operands are unsupported datatypes and return scalar logical false without gather or backend-specific kernels.

GPU memory and residency

strcmp compares host text and returns host logical output. Unsupported numeric resident operands return false without provider access.

Examples

Compare Two Equal Strings

tf = strcmp("RunMat", "RunMat")

Expected output:

tf = logical
   1

Compare String Array With Scalar Text

names = ["red" "green" "blue"];
tf = strcmp(names, "green")

Expected output:

tf = 1×3 logical array
   0   1   0

Compare Character Array Rows

labels = char("cat", "dog", "cat");
tf = strcmp(labels, "cat")

Expected output:

tf = 3×1 logical array
   1
   0
   1

Compare Two Cell Arrays Of Character Vectors

C1 = {'apple', 'pear', 'grape'};
C2 = {'apple', 'peach', 'grape'};
tf = strcmp(C1, C2)

Expected output:

tf = 1×3 logical array
   1   0   1

Handle Missing Strings

vals = ["alpha" missing];
tf = strcmp(vals, "alpha")

Expected output:

tf = 1×2 logical array
   1   0

Implicit Expansion With Column Vector Text

patterns = char("north", "south");
tf = strcmp(patterns, ["north" "east"])

Expected output:

tf = 2×2 logical array
   1   0
   0   0

Using strcmp with coding agents

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

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

FAQ

What types can I pass to strcmp?⌄

Use string arrays, character vectors/arrays, or cell arrays of character vectors. Mixed combinations are accepted and follow MATLAB's implicit expansion rules.

Does strcmp ignore letter case?⌄

No. strcmp is case-sensitive. Use strcmpi for case-insensitive comparisons.

What happens when the inputs contain missing strings?⌄

Missing string scalars compare unequal to every value (including other missing strings), so the result is false.

Can strcmp compare matrices of characters?⌄

Yes. Character arrays compare row-by-row, returning a column vector whose entries tell you whether each row matches.

Does strcmp return numeric or logical results?⌄

It returns logical results. Scalars become logical scalars (Value::Bool), while arrays are returned as logical arrays.

Related Strings functions

Core

blanks · char · compose · convertCharsToStrings · convertContainedStringsToChars · convertStringsToChars · genvarname · int2str · isletter · isspace · isStringScalar · isstrprop · mat2str · native2unicode · newline · num2str · sprintf · sscanf · str2double · str2num · strcmpi · string · string.empty · strings · strlength · strncmp · strncmpi · strtok · unicode2native

Text Analytics

addDependencyDetails · addEntityDetails · addLemmaDetails · addPartOfSpeechDetails · addSentenceDetails · addTypeDetails · bagOfNgrams · bagOfWords · cosineSimilarity · doc2sequence · encode · extractFileText · extractHTMLText · fastTextWordEmbedding · findElement · getAttribute · htmlTree · ind2word · isVocabularyWord · normalizeWords · readWordEmbedding · removeLongWords · removeShortWords · removeStopWords · removeWords · stopWords · tokenDetails · tokenizedDocument · trainWordEmbedding · vaderSentimentScores · vec2word · word2ind · word2vec · wordEncoding · writeWordEmbedding

Transform

append · deblank · erase · eraseBetween · erasePunctuation · eraseURLs · extractAfter · extractBefore · extractBetween · insertAfter · insertBefore · join · lower · pad · replace · replaceBetween · reverse · split · splitlines · strcat · strip · strjoin · strjust · strrep · strsplit · strtrim · upper

Search

contains · endsWith · matches · startsWith · strfind

Pattern

digitsPattern · lettersPattern · pattern · regexpPattern · textBoundary · wildcardPattern

Regex

regexp · regexpi · regexprep

Open-source implementation

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

  • View the source for strcmp 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
  • Errors
  • How strcmp works
  • Does RunMat run strcmp on the GPU?
  • GPU memory and residency
  • Examples
  • Compare Two Equal Strings
  • Compare String Array With Scalar Text
  • Compare Character Array Rows
  • Compare Two Cell Arrays Of Character Vectors
  • Handle Missing Strings
  • Implicit Expansion With Column Vector Text
  • Using strcmp with coding agents
  • FAQ
  • Related Strings functions
  • Core
  • Text Analytics
  • Transform
  • Search
  • Pattern
  • Regex
  • Open-source implementation
  • About RunMat