strcmpi — Compare text inputs for case-insensitive equality with implicit expansion.
strcmpi(A, B) compares text values while ignoring letter case and returns an elementwise logical result.
Syntax
tf = strcmpi(A, B)Inputs
A- Type
Any- Required
- Yes
- Description
- First string, character array, or cellstr operand.
B- Type
Any- Required
- Yes
- Description
- Second string, character array, or cellstr operand.
Returns
tf- Type
LogicalArray- Description
- Case-insensitive logical comparison result.
Errors
RunMat:strcmpi:InvalidInput- When
- At least one input is not a supported text container.
- Message
strcmpi: text inputs must be string/char/cell/string-array values
RunMat:strcmpi:ShapeMismatch- When
- Inputs are not broadcast-compatible for elementwise comparison.
- Message
strcmpi: input sizes are not broadcast-compatible
RunMat:strcmpi:InternalError- When
- Internal logical result assembly failed.
- Message
strcmpi: internal error
RunMat:strcmpi:TooManyOutputs- When
- More than one output is requested.
- Message
strcmpi: too many output arguments
Behavior
strcmpi(A, B) compares text elementwise without distinguishing letter case. It accepts string scalars and arrays, character vectors and matrices, and cell arrays of character vectors, including mixed text containers.
Scalar operands expand against compatible text arrays. Each row of a character matrix is one text element and produces one comparison result. Non-scalar results are logical arrays with the broadcast shape.
Missing string elements compare false even to other missing elements. Whitespace and text length remain significant. For case-sensitive equality, use strcmp; for leading-character comparison, use strncmpi.
Unsupported direct numeric, integer, logical, symbolic, and provider-resident inputs return scalar logical false before provider access or validation of the other operand. Otherwise host cell containers are checked elementwise and malformed elements produce an input error.
Placement and effects
Text comparison runs on the host in native and browser runtimes. There is no GPU text kernel or fusion form. The binding may throw on invalid containers or incompatible shapes, but has no callback, workspace, filesystem, randomness, network, or time effect.
Zero requested outputs discards the evaluated result; more than one requested output is invalid. No device allocation is created or mutated. Distributed-input execution is unsupported; ordinary transfer of host text values is separate.
Examples
Compare scalars ignoring case
tf = strcmpi("RunMat", "runmat")Expected output:
tf = logical 1Search a string row
colors = ["Red" "GREEN" "blue"]; mask = strcmpi(colors, "green")Expected output:
mask = [false true false]Compare character rows
animals = char("Cat", "DOG", "cat"); tf = strcmpi(animals, "cAt")Expected output:
tf = [true; false; true]Compare cell arrays
C1 = {'north', 'East', 'SOUTH'}; C2 = {'NORTH', 'east', 'west'}; tf = strcmpi(C1, C2)Expected output:
tf = [true true false]Compare a character matrix with a string row
patterns = char("alpha", "DELTA"); tf = strcmpi(patterns, ["ALPHA" "delta"])Expected output:
tf = [true false; false true]Missing strings never compare equal
values = ["Active" missing]; mask = strcmpi(values, "active")Expected output:
mask = [true false]Using strcmpi with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how strcmpi changes the result.
Run a small strcmpi example, explain the result, then change one input and compare the output.
FAQ
Which text containers are accepted?⌄
String arrays, character vectors and matrices, and cell arrays of character vectors. Mixed text containers and compatible scalar expansion are supported.
Is whitespace significant?⌄
Yes. Case is ignored, but trailing spaces and different lengths can make strings unequal. Use strtrim or strip when trimming is intended.
Do missing strings compare equal?⌄
No. Missing strings compare false even against another missing string.
Can I compare complex or numeric inputs?⌄
They are unsupported text operands; a direct numeric input returns scalar logical false instead of being converted to text.
How are GPU inputs handled?⌄
There is no GPU text representation. A direct provider-resident numeric input returns scalar logical false without gathering it or accessing the provider.
What happens when both inputs are scalars?⌄
The result is a logical scalar; array inputs produce logical arrays matching the broadcast dimensions.
What does the i mean?⌄
Insensitive to letter case. Use strcmp for case-sensitive equality and strncmpi to compare leading characters.
How do cells and string arrays expand?⌄
A scalar operand expands elementwise against a compatible array; arrays of the same shape compare element by element.
Can character and string operands be mixed?⌄
Yes. Character rows, string scalars, and cellstr values interoperate. For case-insensitive substring search, use contains with IgnoreCase or regexpi.
Related Strings functions
Core
blanks · char · compose · convertCharsToStrings · convertContainedStringsToChars · convertStringsToChars · genvarname · int2str · isletter · isspace · isStringScalar · isstrprop · mat2str · native2unicode · newline · num2str · sprintf · sscanf · str2double · str2num · strcmp · 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
Source you can read
Every RunMat function's source is public. Read exactly how strcmpi is executed, line by line, in Rust.
- View the source for strcmpi 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.