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
    • cell
    • cell2mat
    • cell2struct
    • cellfun
    • cellstr
    • mat2cell
    • num2cell

cell — Create a cell array whose elements begin as empty arrays.

cell allocates a host cell array with a requested shape and empty elements.

Syntax

C = cell()
C = cell(n)
C = cell(sz)
C = cell(m, n, ...)
C = cell("like", prototype)
C = cell(sz, "like", prototype)
C = cell(m, n, ..., "like", prototype)

Inputs

n
Type
SizeArg
Required
Yes
Description
Square size.
sz
Type
SizeArg
Required
Yes
Description
Size vector.
sizes
Type
SizeArg
Required
Variadic
Description
Size vector or individual dimension sizes.
like
Type
StringScalar
Required
Yes
Default
"like"
Description
RunMat prototype selector.
prototype
Type
LikePrototype
Required
Yes
Description
Prototype for result shape or empty element representation.
NameTypeRequiredDefaultDescription
nSizeArgYes—Square size.
szSizeArgYes—Size vector.
sizesSizeArgVariadic—Size vector or individual dimension sizes.
likeStringScalarYes"like"RunMat prototype selector.
prototypeLikePrototypeYes—Prototype for result shape or empty element representation.

Returns

C
Type
Any
Description
Preallocated cell array.
NameTypeDescription
CAnyPreallocated cell array.

Errors

RunMat:cell:TooManyOutputs
When
More than one output is requested.
Message
cell: too many output arguments
RunMat:cell:InvalidInput
When
The argument or option form is invalid.
Message
cell: invalid input arguments
RunMat:cell:InvalidSize
When
A requested size is invalid or cannot be represented.
Message
cell: invalid size arguments
RunMat:cell:Internal
When
Cell allocation encounters an inconsistent internal shape.
Message
cell: internal allocation error
IdentifierWhenMessage
RunMat:cell:TooManyOutputsMore than one output is requested.cell: too many output arguments
RunMat:cell:InvalidInputThe argument or option form is invalid.cell: invalid input arguments
RunMat:cell:InvalidSizeA requested size is invalid or cannot be represented.cell: invalid size arguments
RunMat:cell:InternalCell allocation encounters an inconsistent internal shape.cell: internal allocation error

Shapes

cell() is RunMat's nonconflicting shorthand for an empty 0-by-0 cell array. The form is accepted under either compatibility policy because it does not replace documented behavior.

cell(n) creates an n-by-n cell array. Separate scalar sizes create an N-dimensional result, while a numeric row vector supplies the complete size. One-element inputs use the square form. Trailing singleton dimensions after dimension two are omitted from the stored shape.

Negative finite sizes become zero. Fractional, nonfinite, nonnumeric, column-vector, unrepresentable, and overflowing size forms return structured errors before allocation.

Initial values

Each cell created by a compatible constructor contains an independent empty 0-by-0 double array. Populate cells later with brace assignment.

RunMat's like extension selects the empty element representation and, when no explicit size is present, the outer shape. The extension is rejected under a MATLAB compatibility pin.

Execution

Cell arrays are host containers and end GPU fusion. In RunMat mode, a resident numeric size control can be gathered from its owning provider before host allocation; MATLAB compatibility mode rejects that extension before provider access.

Examples

Create an empty cell array

C = cell();

Expected output:

C is a 0-by-0 cell array

Create a square cell array

C = cell(3);

Expected output:

C is a 3-by-3 cell array

Create a rectangular cell array

C = cell(2, 4);

Expected output:

C is a 2-by-4 cell array

Use an existing array size

A = ones(5, 2);
C = cell(size(A));

Expected output:

C has the same 5-by-2 shape as A

Create an N-dimensional cell array

C = cell(2, 3, 4);

Expected output:

C is a 2-by-3-by-4 cell array

Use exact integer size controls

sz = uint64([4 1]);
C = cell(sz);

Expected output:

C is a 4-by-1 cell array

Select an empty element representation

prototype = false(2, 3);
C = cell(2, 'like', prototype);

Expected output:

Each cell contains an empty logical array

Using cell with coding agents

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

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

FAQ

What does a newly allocated cell contain?⌄

Every compatible constructor cell contains its own empty 0-by-0 double array.

Can a cell array have a zero dimension?⌄

Yes. Any zero size produces an empty cell array with the normalized requested shape.

Are negative or fractional sizes allowed?⌄

Finite fractional sizes are invalid. Signed negative sizes become zero. All eight integer classes are decoded exactly, and allocation fails if the element count exceeds platform limits.

Can size controls reside on the GPU?⌄

The documented constructor is host-only. In RunMat mode, the named GPU-size extension can gather a resident size control before allocating the host cell array.

What about N-dimensional cell arrays?⌄

Supply separate scalar dimensions or a numeric row size vector. Trailing singleton dimensions after dimension two are omitted from the stored shape.

Does cell copy values from another array?⌄

No. Size inputs describe only the outer shape; the optional RunMat prototype chooses shape or empty representation, not payload values.

Related Cells functions

cell2mat · cell2struct · cellfun · cellstr · mat2cell · num2cell

Source you can read

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

  • View the source for cell 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
  • Shapes
  • Initial values
  • Execution
  • Examples
  • Create an empty cell array
  • Create a square cell array
  • Create a rectangular cell array
  • Use an existing array size
  • Create an N-dimensional cell array
  • Use exact integer size controls
  • Select an empty element representation
  • Using cell with coding agents
  • FAQ
  • Related Cells functions
  • Source you can read
  • About RunMat