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

string.empty — Construct empty string arrays with MATLAB-compatible dimension semantics.

string.empty constructs empty string arrays, returning 0x0 by default. When dimensions are provided, it preserves MATLAB-compatible empty-shape semantics so the total element count remains zero.

Syntax

S = string.empty()
S = string.empty(sz)
S = string.empty(m, n...)
S = string.empty(___, "like", p)

Inputs

sz
Type
SizeArg
Required
Yes
Description
Size vector or scalar.
m
Type
SizeArg
Required
Yes
Description
First dimension.
n...
Type
SizeArg
Required
Variadic
Description
Additional dimensions.
dims...
Type
SizeArg
Required
Variadic
Description
Optional explicit dimensions.
like
Type
StringScalar
Required
Yes
Default
"like"
Description
Literal option keyword "like".
p
Type
LikePrototype
Required
Yes
Description
Prototype supplying trailing dimensions.
NameTypeRequiredDefaultDescription
szSizeArgYes—Size vector or scalar.
mSizeArgYes—First dimension.
n...SizeArgVariadic—Additional dimensions.
dims...SizeArgVariadic—Optional explicit dimensions.
likeStringScalarYes"like"Literal option keyword "like".
pLikePrototypeYes—Prototype supplying trailing dimensions.

Returns

S
Type
Any
Description
Empty string array with at least one zero dimension.
NameTypeDescription
SAnyEmpty string array with at least one zero dimension.

Errors

RunMat:string.empty:InvalidSize
When
Size inputs are not valid numeric dimensions or vectors.
Message
string.empty: size inputs must be numeric scalars or size vectors
RunMat:string.empty:LikeMissingPrototype
When
"like" keyword is present without a prototype.
Message
string.empty: expected prototype after 'like'
RunMat:string.empty:LikeDuplicate
When
Multiple "like" specifications are supplied.
Message
string.empty: multiple 'like' prototypes are not supported
IdentifierWhenMessage
RunMat:string.empty:InvalidSizeSize inputs are not valid numeric dimensions or vectors.string.empty: size inputs must be numeric scalars or size vectors
RunMat:string.empty:LikeMissingPrototype"like" keyword is present without a prototype.string.empty: expected prototype after 'like'
RunMat:string.empty:LikeDuplicateMultiple "like" specifications are supplied.string.empty: multiple 'like' prototypes are not supported
RunMat:string.empty:NonEmptyShapeParsed dimensions do not produce an empty array shape.string.empty: at least one dimension must be zero
RunMat:string.empty:InternalErrorInternal empty string-array construction failed.string.empty: internal error

Behavior

string.empty or string.empty() yields a 0×0 string array.

string.empty(n) produces a 0×n array. The leading dimension is fixed at 0, so the result is still empty even if n > 0.

string.empty(m, n, p, ...) returns a 0×n×p×… array. All trailing dimensions are honoured while the leading dimension remains zero.

You can provide a single size vector such as string.empty([0 5 3]); the first entry is ignored beyond confirming it is non-negative, and the remaining entries set the trailing dimensions.

string.empty(___, 'like', prototype) copies the trailing dimensions from prototype when you do not supply explicit sizes. Any dimensions you pass explicitly take precedence. GPU-resident prototypes are automatically gathered so their shape can be inspected.

Size inputs must be finite, real, non-negative integers. Fractional and negative values, including negative fixed-width integers, raise an error.

The result always resides on the host; there is no GPU counterpart for string arrays.

Execution and placement

The empty result is host-resident. Resident dimensions or prototypes can gather before validation; no GPU construction kernel or fusion path exists.

Examples

Creating a 0x0 string array

S = string.empty

Expected output:

S =
  0x0 string array

Building a 0xN string row vector

row = string.empty(5)

Expected output:

row =
  0x5 string array

Creating a 0xN string array with extra dimensions

cube = string.empty(0, 4, 3)

Expected output:

cube =
  0x4x3 string array

Using a size vector with string.empty

sz = [0 2 5];
grid = string.empty(sz)

Expected output:

grid =
  0x2x5 string array

Resetting a preallocated string array to empty

A = strings(3, 2);  % Some application-specific strings
A = string.empty(size(A))

Expected output:

A =
  0x2 string array

Preserving higher-dimensional layout while empty

layout = string.empty([2 0 4 6])

Expected output:

layout =
  0x0x4x6 string array

Reusing the shape of an existing array with 'like'

proto = strings(3, 2);
sameCols = string.empty('like', proto)

Expected output:

sameCols =
  0x2 string array

Using string.empty with coding agents

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

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

FAQ

Why is the first dimension always zero?⌄

The leading dimension is forced to zero, so the result contains no elements. RunMat follows this empty-construction rule for the supported forms.

Can I request negative or fractional dimensions?⌄

Fractional and negative floating dimensions reject. Negative fixed-width integer dimensions currently clamp to zero in RunMat's shared constructor parser; this remains a documented compatibility gap.

Does string.empty(n) create space for n elements?⌄

No. It returns a 0×n array, which still has zero elements. Use strings(n) if you want an array of string scalars that you can fill later.

Can I combine scalars and size vectors?⌄

Yes. Calls like string.empty([0 3], 5) flatten to string.empty(0, 3, 5) internally.

What does the 'like' option do?⌄

'like', prototype copies the trailing dimensions from prototype when you omit explicit sizes. The first dimension is still forced to 0, so the result remains empty. The prototype is gathered automatically if it resides on the GPU.

Does the result share storage with existing arrays?⌄

No. Each result is a new empty string-array value with its own shape metadata; there is no payload to alias.

Is there a GPU-accelerated variant?⌄

No. The result is host text. A resident prototype or size argument may be gathered to inspect its shape or values, but construction does not run a GPU kernel.

How do I obtain a 0x0 string array quickly?⌄

Call string.empty or string.empty(). It is equivalent to strings(0) but makes the intention explicit.

Can I use size output directly?⌄

Yes. Expressions like string.empty(size(existingArray)) are supported. The first element of the size vector is ignored when constructing the new array so that the first dimension is zero.

What happens if I pass an empty array as the size vector?⌄

string.empty([]) returns the canonical 0×0 string array, just like calling string.empty with no arguments.

What if I provide both explicit dimensions and a 'like' prototype?⌄

Explicit dimensions set the output shape; the prototype is still validated but does not override them. Unsupported extra arguments raise an error.

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

Source you can read

Every RunMat function's source is public. Read exactly how string.empty is executed, line by line, in Rust.

  • View the source for string.empty 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 0x0 string array
  • Building a 0xN string row vector
  • Creating a 0xN string array with extra dimensions
  • Using a size vector with string.empty
  • Resetting a preallocated string array to empty
  • Preserving higher-dimensional layout while empty
  • Reusing the shape of an existing array with 'like'
  • Using string.empty with coding agents
  • FAQ
  • Related Strings functions
  • Core
  • Text Analytics
  • Transform
  • Search
  • Pattern
  • Regex
  • Source you can read
  • About RunMat