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
    • 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

sz
Type
SizeArg
Required
Yes
Description
Size vector or scalar side length.
m
Type
SizeArg
Required
Yes
Description
First array dimension.
n...
Type
SizeArg
Required
Variadic
Description
Additional array dimensions.
dims...
Type
SizeArg
Required
Variadic
Description
Optional explicit size dimensions.
like
Type
StringScalar
Required
Yes
Default
"like"
Description
Literal option keyword "like".
p
Type
LikePrototype
Required
Yes
Description
Prototype value supplying output shape when dims are omitted.
fill
Type
StringScalar
Required
Yes
Default
"empty"
Description
Fill mode keyword: "empty" or "missing".
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

S
Type
Any
Description
Preallocated string array.
NameTypeDescription
SAnyPreallocated string array.

Errors

RunMat:strings:InvalidSize
When
Size arguments are not valid numeric scalar/vector dimensions.
Message
strings: size arguments must be numeric scalars or vectors
RunMat:strings:LikeMissingPrototype
When
"like" is provided without a following prototype.
Message
strings: expected prototype after 'like'
RunMat:strings:LikeDuplicate
When
Multiple "like" options are supplied in one call.
Message
strings: multiple 'like' specifications are not supported
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

Behavior

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.

Execution and placement

Construction produces host strings. Resident dimensions or prototypes are gathered through the owning provider. The missing-fill and like-prototype forms are RunMat extensions.

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

Source you can read

Every RunMat function's source is public. 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 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
  • Execution and placement
  • 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
  • Source you can read
  • About RunMat