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 | Dictionary 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) |
writedictionary | Write dictionary to file (Since R2024b) |
readdictionary | Create dictionary from file (Since R2024b) |
Classes
Topics
- Create and Manage Dictionaries
Use dictionaries to organize data as key-value pairs. (Since R2022b)
- Manage Data Types in Dictionaries
Store and access different data types in dictionaries.
- Use Dictionaries to Process Text Data
Create a dictionary from text data and extract information.
- Dictionaries and Custom Classes
Modify custom classes for expected behavior in dictionaries.