dictionary — Create a key-value dictionary object.
dictionary(keys, values) creates a host dictionary object. Alternating key/value pairs are also accepted, including array-valued pairs.
Syntax
d = dictionary()
d = dictionary(keys, values)
d = dictionary(k1, v1, ..., kN, vN)Inputs
keys- Type
Any- Required
- Yes
- Description
- Uniform or cell-wrapped dictionary keys.
values- Type
Any- Required
- Yes
- Description
- Same-size values, or scalar values expanded to each key.
keyValuePair1- Type
Any- Required
- Yes
- Description
- First key/value argument pair.
keyValuePairN- Type
Any- Required
- Variadic
- Description
- Additional key/value argument pairs.
Returns
d- Type
Any- Description
- Scalar dictionary object with configured Keys/Values entry cells.
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
Keys and values must have the same size unless the value input is scalar, in which case it expands to every key.
String, numeric, logical, char, and cell collections are expanded into entries and normalized to one compatible configured key class and one compatible configured value class.
All eight integer classes remain exact, including uint64 keys beyond binary64's exact range. Construction, lookup, assignment, and removal compare authoritative configured-class integers.
Duplicate keys keep their first insertion position and the last supplied value.
Multi-key lookup preserves the configured uniform value class and the query shape; scalar lookup returns a scalar. Non-scalar assignment values must match the key-query shape, while scalar assignment expands.
Resident keys or values are a RunMat-only interactive extension. Compatibility mode rejects them before provider access; RunMat mode gathers them exactly through the owning provider.
Concrete MATLAB dictionary class metadata and unsupported heterogeneous object-type conversions remain recorded general gaps.
Residency and fusion
Dictionary objects are host metadata containers. Resident input is a RunMat-only extension gated before exact download through the owning provider.
Construction is a pure, potentially suspending host operation. The canonical default Runtime binding gathers retained values through their owning provider after extension admission, is a fusion boundary, and links portably on native and Wasm.
Finite Managed metadata and entry-list scratch are not yet owned by exact quotes; such invocations reject before gather or raw allocation. Ordinary unbounded execution checks its original allocation/cancellation authority before publication. This is a recorded L25 limit, not finite ownership completion.
Construction, shape, and mutation
dictionary() creates an empty host dictionary. A two-argument keys/values form expands each supported collection into entries; additional alternating arguments each contribute a key/value pair. Odd argument counts reject.
Cell entries are enumerated in logical column-major order. Multi-key lookups retain the entire query shape, including N-D pages; fallback cell results are built using the canonical cell column-major boundary.
The configured real numeric class is authoritative for comparison and publication. Single entries retain native binary32 payloads, scalar lookup retains their class, and homogeneous multi-key lookup returns a Single array with the query shape. Conversion of integer queries and assigned values to Single uses native integer-to-binary32 rounding. Complex arrays and rich object payloads are not promised as per-element entry expansion. Mixed unsupported class conversions reject rather than establishing a second class authority.
Example
Create a dictionary
D = dictionary(["a" "b"], [1 2])Using dictionary with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how dictionary changes the result.
Run a small dictionary example, explain the result, then change one input and compare the output.
Related Table functions
Table
array2table · array2timetable · categorical · cell2table · groupsummary · head · iscategorical · isordinal · istable · istimetable · ordinal · pivot · rowfilter · struct2table · table · 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 dictionary is executed, line by line, in Rust.
- View the source for dictionary 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.