Dictionaries
Map data with keys that index values
A dictionary is a data structure that associates each key with a corresponding value. Keys and values can be of any data type, providing more flexibility for data access than array indices and improved performance.
dictionary
is recommended over
containers.Map
because it supports more data types as
keys and values and provides better performance. (since R2022b)
Functions
dictionary | Object that maps unique keys to values (Since R2022b) |
configureDictionary | Create dictionary with specified key and value types (Since R2023b) |
insert | Add entries to a dictionary (Since R2023b) |
lookup | Find value in dictionary by key (Since R2023b) |
remove | Remove dictionary entries (Since R2023b) |
entries | Key-value pairs of dictionary (Since R2022b) |
keys | Keys of dictionary (Since R2022b) |
values | Values of dictionary (Since R2022b) |
types | Types of dictionary keys and values (Since R2022b) |
numEntries | Number of key-value pairs in dictionary (Since R2022b) |
isConfigured | Determine if dictionary has types assigned to keys and values (Since R2022b) |
isKey | Determine if dictionary contains key (Since R2022b) |
keyHash | Generate hash code for dictionary key (Since R2022b) |
keyMatch | Determine if two dictionary keys are the same (Since R2022b) |
Classes
Topics
- Map Data with Dictionaries
Use dictionaries to store key-value pairs of different data types. (Since R2022b)
- Dictionaries and Custom Classes
Modify custom classes for expected behavior in dictionaries.