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(variables...)
T = table(Size=sz, VariableTypes=varTypes, Name=Value...)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
variables | Any | Variadic | — | Variables to assemble as table columns. |
Size | SizeArg | Yes | — | Two-element table size vector [rows variables]. |
VariableTypes | Any | Yes | — | String array or cellstr naming each preallocated variable type. |
VariableNames | Any | No | — | Optional names for the preallocated variables. |
RowNames | Any | No | — | Optional names for the preallocated rows. |
Returns
| Name | Type | Description |
|---|---|---|
out | Any | Result value. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:table:InvalidArgument | Arguments or table metadata are invalid. | table: invalid argument |
RunMat:table:InvalidIndex | Table indexing is invalid. | table: invalid index |
RunMat:table:InvalidVariable | A table variable name or value is invalid. | table: invalid variable |
RunMat:readtable:IOError | readtable cannot open or read the requested file. | readtable: file read failed |
RunMat:readtable:UnsupportedFileType | readtable receives a file type outside the text or spreadsheet import backends. | readtable: unsupported file type |
How table works
- 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. Sizeaccepts floating or any built-in integer class, must contain exactly two nonnegative integer values, and must request the same number of variables listed byVariableTypes.VariableNamesandRowNamescan 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.
Examples
Creating A Table From Existing Variables
age = int16([31; 42]);
score = single([0.8; 0.9]);
T = table(age, score, VariableNames=["Age" "Score"])Expected output:
T = 2x2 tablePreallocating Integer Variables
T = table(Size=uint16([3 2]), VariableTypes=["int32" "uint64"], VariableNames=["Count" "Identifier"])Expected output:
T = 3x2 table with zero-filled int32 and uint64 variablesUsing 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
array2table · array2timetable · categorical · cell2table · dictionary · groupsummary · head · height · iscategorical · isordinal · istable · istimetable · ordinal · pivot · rowfilter · struct2table · table2array · table2cell · table2struct · table2timetable · timerange · timetable · timetable2table · uitable · vartype · width
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. 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 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.