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
    • contains
    • endsWith
    • matches
    • startsWith
    • strfind

startsWith — Test whether text values start with specified prefixes using MATLAB-compatible broadcasting and case options.

startsWith(str, pattern) returns logical results indicating whether each text element begins with a corresponding prefix. It supports MATLAB-compatible string, char, and cellstr containers plus implicit expansion rules.

Syntax

tf = startsWith(str, pat)
tf = startsWith(str, pat, ignoreCase)
tf = startsWith(str, pat, "IgnoreCase", value)
tf = startsWith(str, pat, nameValuePairs...)

Inputs

NameTypeRequiredDefaultDescription
strAnyYes—Text input (string/char/cell/string array).
patAnyYes—Pattern text (string/char/cell/string array).
ignoreCaseAnyYesfalseLogical flag controlling case-sensitive matching.
nameStringScalarYes"IgnoreCase"Option name (`"IgnoreCase"`).
valueAnyYes—Option value for `"IgnoreCase"`.
nameValuePairs...AnyVariadic—Name-value option pairs (`"IgnoreCase"`, value).

Returns

NameTypeDescription
tfLogicalArrayLogical result indicating whether each text element starts with the pattern.

Errors

IdentifierWhenMessage
RunMat:startsWith:InvalidInputText or pattern input is not a supported text container.startsWith: text and pattern inputs must be text values
RunMat:startsWith:InvalidOptionIgnoreCase option arguments are invalid or malformed.startsWith: invalid option arguments
RunMat:startsWith:ShapeMismatchText and pattern inputs are not broadcast-compatible.startsWith: input sizes are not broadcast-compatible
RunMat:startsWith:InternalErrorInternal logical result assembly failed.startsWith: internal error

How startsWith works

  • Accepts text inputs as string scalars/arrays, character vectors/arrays, or cell arrays of character vectors.
  • Accepts patterns in the same formats; scalar inputs expand across the other argument following MATLAB broadcast rules.
  • Missing strings (<missing>) never match any pattern.
  • Empty patterns ("" or '') always match non-missing text elements.
  • Patterns that are <missing> never match and therefore return false.
  • Character arrays treat each row as an independent element; zero-row character arrays yield empty outputs.
  • MATLAB-compatible mode accepts the documented 'IgnoreCase', logicalValue name-value form. RunMat mode additionally accepts positional, numeric, textual, and resident scalar flag forms behind explicit compatibility extensions.
  • All eight integer classes are read exactly as RunMat-only IgnoreCase controls: zero is false and every nonzero value is true.
  • Returns a logical scalar when the broadcasted size is one element, otherwise returns a logical array.

Does RunMat run startsWith on the GPU?

startsWith performs host-side prefix comparison. Numeric resident values in text roles reject without provider access; admitted automatic controls gather, and explicit controls require RunMat mode.

GPU memory and residency

startsWith executes on host text. Automatic placement remains transparent for an admitted scalar control, while explicit gpuArray intent is compatibility-gated before gather.

Examples

Determine whether a string starts with a prefix

tf = startsWith("RunMat Accelerate", "RunMat")

Expected output:

tf = logical
   1

Perform a case-insensitive prefix check

tf = startsWith("RunMat", "run", 'IgnoreCase', true)

Expected output:

tf = logical
   1

Ignoring case with a positional flag

tf = startsWith("RUNMAT", "run", true)

Expected output:

tf = logical
   1

Apply a scalar prefix to every element of a string array

labels = ["alpha" "beta" "gamma"];
tf = startsWith(labels, "a")

Expected output:

tf = 1×3 logical array
   1   0   0

Match element-wise prefixes with implicit expansion

names = ["hydrogen"; "helium"; "lithium"];
prefixes = ["hyd"; "hel"; "lit"];
tf = startsWith(names, prefixes)

Expected output:

tf = 3×1 logical array
   1
   1
   1

Test prefixes for a cell array of character vectors

C = {'Mercury', 'Venus', 'Mars'};
tf = startsWith(C, 'M')

Expected output:

tf = 1×3 logical array
   1   0   1

Provide multiple prefixes as a column vector

tf = startsWith("saturn", ['s'; 'n'; 'x'])

Expected output:

tf = 3×1 logical array
   1
   0
   0

Handle empty and missing values

texts = ["", "<missing>"];
tf = startsWith(texts, "")

Expected output:

tf = 1×2 logical array
   1   0

Using startsWith with coding agents

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

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

FAQ

What types can I pass to startsWith?⌄

Use string scalars/arrays, character vectors/arrays, or cell arrays of character vectors for both arguments. Mixed combinations are accepted, and RunMat performs MATLAB-style implicit expansion when the array sizes differ.

How do I ignore letter case?⌄

For MATLAB-compatible code, supply 'IgnoreCase', true. RunMat mode also accepts textual, numeric, positional, and resident scalar extensions; the default remains case-sensitive.

What happens with empty patterns?⌄

Empty patterns ("" or '') always match non-missing text elements. When the text element is missing (<missing>), the result is false.

Can I provide multiple prefixes at once?⌄

Yes. Provide pattern as a string array, character array, or cell array of character vectors. RunMat applies implicit expansion so that scalar inputs expand across the other argument automatically.

How are missing strings treated?⌄

Missing string scalars (displayed as <missing>) never match any pattern and produce false in the result. Use ismissing if you need to handle missing values separately.

Does startsWith run on the GPU?⌄

No. Text and pattern values are host-only. Automatically placed scalar controls can gather transparently, while explicitly resident controls are admitted only by the RunMat compatibility extension.

Does startsWith preserve the input shape?⌄

Yes. The output is a logical array whose shape reflects the MATLAB-style implicit expansion result. When that shape contains exactly one element, the builtin returns a logical scalar.

Related Strings functions

Search

contains · endsWith · matches · strfind

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

Core

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

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 startsWith is executed, line by line, in Rust.

  • View the source for startsWith 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 startsWith works
  • Does RunMat run startsWith on the GPU?
  • GPU memory and residency
  • Examples
  • Determine whether a string starts with a prefix
  • Perform a case-insensitive prefix check
  • Ignoring case with a positional flag
  • Apply a scalar prefix to every element of a string array
  • Match element-wise prefixes with implicit expansion
  • Test prefixes for a cell array of character vectors
  • Provide multiple prefixes as a column vector
  • Handle empty and missing values
  • Using startsWith with coding agents
  • FAQ
  • Related Strings functions
  • Search
  • Text Analytics
  • Transform
  • Core
  • Pattern
  • Regex
  • Open-source implementation
  • About RunMat