cell — Create preallocated cell arrays whose elements contain empty double arrays.
cell preallocates a host cell array of a requested size. Every cell created by a documented form contains a 0×0 double array. RunMat accepts exact size controls in all eight integer classes without converting them through binary64.
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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
n | SizeArg | Yes | — | Square size. |
sz | SizeArg | Yes | — | Size vector. |
dims | SizeArg | Variadic | — | Dimension sizes. |
like_kw | StringScalar | Yes | "like" | Like keyword. |
prototype | LikePrototype | Yes | — | Prototype value used to infer element class. |
Returns
| Name | Type | Description |
|---|---|---|
C | Any | Output cell array. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:cell:InvalidInput | Input arguments or option forms are invalid. | cell: invalid input arguments |
RunMat:cell:InvalidSize | Requested size arguments are invalid or unsupported. | cell: invalid size arguments |
| — | Internal cell allocation or conversion failed. | cell: internal error |
How cell works
- RunMat accepts
cell()as a nonconflicting shorthand for a0×0empty cell array; this form is not listed in the current public syntax and is not speculatively mode-gated from documentation silence. cell(n)returns ann×ncell array of0×0double arrays.cell(sz1, ..., szN)returns an N-D cell array with the requested dimensions and ignores trailing singleton dimensions after dimension two.cell(sz)orcell(size(A))accepts a row size vector. A one-element size input follows the squaren×nform; a column size vector is not a documented input.- Size controls accept single, double,
int8,int16,int32,int64,uint8,uint16,uint32, oruint64. Integer storage is decoded exactly, finite fractional values reject, and signed negative values are treated as zero. - The
'like'prototype selector and resident GPU size controls are separately registered RunMat extensions and reject in MATLAB-compatible mode.
Does RunMat run cell on the GPU?
Cell construction terminates GPU fusion because the heterogeneous container lives on the host heap. In RunMat extension mode, a resident size control is gathered from its owning provider without floating reinterpretation and the host cell array is allocated from the decoded dimensions. MATLAB-compatible mode rejects that extension before provider dispatch or gather.
GPU memory and residency
No. The result is always a host cell array. The public constructor does not document interactive gpuArray input; RunMat's named GPU-size extension can gather an exact resident size control before host allocation when extension mode is enabled.
Examples
Creating a square cell array of empty placeholders
C = cell(3);
size(C)Expected output:
ans =
3 3Creating a rectangular 2-by-4 cell array
C = cell(2, 4);
class(C)Expected output:
ans =
'cell'Creating a 3-D cell array
C = cell(2, 3, 4);
size(C)Expected output:
ans =
2 3 4Matching the size of an existing matrix
A = ones(5, 2);
C = cell(size(A));
size(C)Expected output:
ans =
5 2Using an exact typed-integer row size vector
sz = uint64([4 1]);
C = cell(sz);
size(C)Expected output:
ans =
4 1Verifying that every cell starts with []
C = cell(2, 2);
isequal(C{1,1}, [], C{2,2}, [])Expected output:
ans = logical
1Using 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 values do new cells contain?⌄
Every cell created by a documented constructor form contains the empty 0×0 double array []. RunMat's separately mode-gated 'like' extension can choose another empty value, but that is not part of the compatibility contract.
Are negative or fractional sizes allowed?⌄
Finite fractional sizes are invalid. A signed negative integer size is treated as zero. All eight integer classes are parsed exactly; allocation still fails if the resulting element count exceeds platform limits.
Can I create zero-sized cell arrays?⌄
Yes. You can use cell(0), cell(0, n), or supply a size vector containing zeros. RunMat returns an empty cell array with the requested shape.
Can size controls reside on the GPU?⌄
The documented constructor has no interactive gpuArray surface. RunMat can gather a resident size vector and allocate the host cell array when its named GPU-size extension is enabled; MATLAB-compatible mode rejects before provider access.
What about N-dimensional cell arrays?⌄
RunMat supports N-dimensional cell arrays. Supply scalar dimensions or a row size vector; trailing dimensions whose size is one are ignored after the second dimension.
Does cell copy data from existing containers?⌄
No. The builtin only allocates empty cells. Populate the elements afterwards with assignments such as C{1,2} = magic(3);.
Related Cells functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. 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 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.