table — Create a table from column variables or preallocate numeric table variables.
table(var1, ..., varN) stores arrays with the same row count as named table variables. table(Size=sz, VariableTypes=types) preallocates numeric variables from a two-element size vector.
Syntax
T = table()
T = table(variables...)
T = table(variables..., Name=Value)
T = table(Size=sz, VariableTypes=varTypes, Name=Value...)Inputs
variables- Type
Any- Required
- Variadic
- Description
- Arrays with a common row count; each retains its native class and trailing shape.
variables- Type
Any- Required
- Variadic
- Description
- Data variables followed by VariableNames or RowNames controls.
Size- Type
SizeArg- Required
- Yes
- Description
- Two-element exact nonnegative numeric [rows variables] vector.
VariableTypes- Type
Any- Required
- Yes
- Description
- One numeric class name for every requested variable.
VariableNames- Type
Any- Required
- No
- Description
- Optional explicit variable names.
RowNames- Type
Any- Required
- No
- Description
- Optional row labels.
Returns
T- Type
Any- Description
- Scalar table object retaining named variables and public Properties.
Errors
RunMat:table:InvalidArgument- When
- Arguments or table metadata are invalid.
- Message
table: invalid argument
RunMat:table:InvalidVariable- When
- A table variable name or value is invalid.
- Message
table: invalid variable
RunMat:table:InvalidIndex- When
- Table indexing is invalid.
- Message
table: invalid index
Behavior
Each input variable keeps its own class, shape after the row dimension, and exact values.
Preallocation currently supports double, single, and all eight built-in integer variable types. Integer columns are initialized with same-class zeros.
Size accepts floating or any built-in integer class, must contain exactly two nonnegative integer values, and must request the same number of variables listed by VariableTypes.
VariableNames and RowNames can label the variables and rows. Names must satisfy the table naming and uniqueness rules.
Other documented preallocation types, including logical, string, categorical, datetime, duration, and calendar duration, remain implementation gaps.
Residency and fusion
Tables are host containers. Automatically resident variables may gather transparently; explicit GPU variables require RunMat extension mode.
The canonical default binding roots retained arguments across provider gathers and preserves source class/payload owners. This pure host constructor may suspend, is a fusion boundary, and uses portable Runtime execution on native and Wasm; no table GPU kernel is advertised.
Finite Managed construction is rejected before raw preallocation, name/schema scratch, or gather. A complete quoted column/metadata allocation vertical remains L25 work. Other documented preallocation classes and richer empty-table metadata are explicit unsupported implementation frontiers, not inferred as implemented.
Constructor and schema
table() creates an empty host table. Data-variable construction accepts heterogeneous supported arrays but requires an equal leading row count; trailing dimensions and native payloads are retained. VariableNames defaults to Var1, Var2, and so on.
Size and VariableTypes must occur together and cannot be mixed with data variables. Variable type and explicit variable-name counts must match the requested width. Size must be a real two-element nonnegative integral vector in platform range; unsupported variable types reject.
Variable and row labels follow existing table naming rules, including uniqueness and reserved-name validation. Empty and zero-width tables retain existing table metadata limitations; positive height without any variables is not represented by a separate table-height owner.
Examples
Creating A Table From Existing Variables
age = int16([31; 42]);
score = single([0.8; 0.9]);
T = table(age, score, VariableNames=["Age" "Score"])Preallocating Integer Variables
T = table(Size=uint16([3 2]), VariableTypes=["int32" "uint64"], VariableNames=["Count" "Identifier"])Using table with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how table changes the result.
Run a small table example, explain the result, then change one input and compare the output.
FAQ
Do integer variables lose precision when stored in a table?⌄
No. Each integer variable retains its exact signedness, width, shape, and values, including int64 and uint64 values above flintmax.
Can a table contain variables of different types?⌄
Yes. Variables can use different supported classes and widths as long as they have the same number of rows.
Related Table functions
Table
array2table · array2timetable · categorical · cell2table · dictionary · groupsummary · head · iscategorical · isordinal · istable · istimetable · ordinal · pivot · rowfilter · struct2table · table2array · table2cell · table2struct · table2timetable · timerange · timetable · timetable2table · uitable · vartype
Indexing
dictionary.subsasgn · dictionary.subsref · table.subsasgn · table.subsref
Source you can read
Every RunMat function's source is public. Read exactly how table is executed, line by line, in Rust.
- View the source for table 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.