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

strings — Preallocate string arrays filled with empty string scalars using MATLAB-compatible size syntax.

strings creates string arrays populated with empty string scalars (""). It supports MATLAB-compatible scalar, vector, and variadic dimension forms for preallocation.

Syntax

S = strings()
S = strings(sz)
S = strings(m, n...)
S = strings(___, "like", p)
S = strings(___, fill)

Inputs

NameTypeRequiredDefaultDescription
szSizeArgYes—Size vector or scalar side length.
mSizeArgYes—First array dimension.
n...SizeArgVariadic—Additional array dimensions.
dims...SizeArgVariadic—Optional explicit size dimensions.
likeStringScalarYes"like"Literal option keyword "like".
pLikePrototypeYes—Prototype value supplying output shape when dims are omitted.
fillStringScalarYes"empty"Fill mode keyword: "empty" or "missing".

Returns

NameTypeDescription
SAnyPreallocated string array.

Errors

IdentifierWhenMessage
RunMat:strings:InvalidSizeSize arguments are not valid numeric scalar/vector dimensions.strings: size arguments must be numeric scalars or vectors
RunMat:strings:LikeMissingPrototype"like" is provided without a following prototype.strings: expected prototype after 'like'
RunMat:strings:LikeDuplicateMultiple "like" options are supplied in one call.strings: multiple 'like' specifications are not supported
RunMat:strings:SizeOverflowRequested dimensions overflow platform limits.strings: requested size exceeds platform limits
RunMat:strings:InternalErrorInternal string array construction failed.strings: internal error

How strings works

  • strings with no inputs returns a 1×1 string array containing "".
  • strings(n) produces an n-by-n array of empty strings. Double, single, and all eight integer classes are accepted for the integer-valued size.
  • strings(sz1,...,szN) and strings(sz) accept finite integer sizes. Negative values are treated as zero, and trailing dimensions of size one beyond the second dimension are ignored.
  • Setting any dimension to 0 yields an empty array whose remaining dimensions still shape the result (for example, strings(0, 5, 3) is a 0×5×3 string array).
  • The "missing" or "empty" fill option is a mode-gated RunMat extension; the documented strings contract creates empty strings.
  • The "like" prototype form is a mode-gated RunMat extension. It inspects only prototype shape and does not convert an integer prototype payload.
  • Fractional, infinite, NaN, or platform-unrepresentable sizes reject before allocation; negative finite integer values become zero.
  • Only numeric or logical size arguments are supported. Other types (strings, structs, objects) raise descriptive errors.

Does RunMat run strings on the GPU?

strings never allocates string data on the GPU. Documented GPU-array size values and automatically resident size intermediates gather through their owning provider before exact validation. The RunMat-only "like" form follows the same host allocation rule.

Examples

Creating a square array of empty strings

S = strings(4)

Expected output:

S = 4x4 string
    ""    ""    ""    ""
    ""    ""    ""    ""
    ""    ""    ""    ""
    ""    ""    ""    ""

Preallocating with separate dimension arguments

grid = strings(2, 3, 4)

Expected output:

grid = 2x3x4 string
grid(:,:,1) =
    ""    ""    ""
    ""    ""    ""

Cloning the size of another array

A = magic(3);
placeholders = strings(size(A))

Expected output:

placeholders = 3x3 string
    ""    ""    ""
    ""    ""    ""
    ""    ""    ""

Handling zero dimensions

emptyRow = strings(0, 5)

Expected output:

emptyRow = 0x5 string

Ignoring trailing singleton dimensions beyond the second

column = strings(3, 1, 1, 1);
sz = size(column)

Expected output:

sz =
     3     1

Filling arrays with missing string scalars

placeholders = strings(2, 3, "missing")

Expected output:

placeholders = 2x3 string
    <missing>    <missing>    <missing>
    <missing>    <missing>    <missing>

Matching an existing array's shape

proto = zeros(3, 2);
labels = strings("like", proto)

Expected output:

labels = 3x2 string
    ""    ""
    ""    ""
    ""    ""

Treating a negative size as zero

emptySquare = strings(-3)

Expected output:

emptySquare = 0x0 string

Using strings with coding agents

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

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

FAQ

How is strings different from string?⌄

strings preallocates empty string scalars, while string converts existing data to string scalars. Use strings to reserve space, then assign values later.

Can I use non-integer sizes such as 2.5?⌄

No. All size arguments must be finite integers. Fractional or NaN values raise descriptive errors.

How do I create missing string values (<missing>)?⌄

In runmat mode, pass "missing" as an extension option—for example, strings(2, 3, "missing"). MATLAB-compatible mode accepts the documented empty-string construction forms only.

How can I reuse the size of an existing array?⌄

RunMat mode provides strings("like", prototype) as an extension. For portable source, use strings(size(prototype)).

Does the output ever live on the GPU?⌄

No. strings always returns a host-resident string array. GPU inputs supplying sizes are gathered before validation.

How can I create a row versus column vector?⌄

Use strings(1, n) for a row and strings(n, 1) for a column. Dimensions beyond the second are retained when they are not one; trailing singleton dimensions beyond the second are ignored.

Can I pass non-numeric types such as structs or string arrays as size inputs?⌄

No. Only numeric or logical values are accepted. Other types produce MATLAB-compatible usage errors.

Is there an equivalent to string.empty?⌄

Yes. strings(0) returns the same 0-by-0 empty string array as string.empty.

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 · strcmpi · string · string.empty · 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 strings is executed, line by line, in Rust.

  • View the source for strings 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 strings works
  • Does RunMat run strings on the GPU?
  • Examples
  • Creating a square array of empty strings
  • Preallocating with separate dimension arguments
  • Cloning the size of another array
  • Handling zero dimensions
  • Ignoring trailing singleton dimensions beyond the second
  • Filling arrays with missing string scalars
  • Matching an existing array's shape
  • Treating a negative size as zero
  • Using strings with coding agents
  • FAQ
  • Related Strings functions
  • Core
  • Text Analytics
  • Transform
  • Search
  • Pattern
  • Regex
  • Open-source implementation
  • About RunMat