values
Description
Examples
Query Values of Dictionary
Create a dictionary containing three key-value pairs that map numbers to strings.
names = ["Unicycle" "Bicycle" "Tricycle"]; wheels = [1 2 3]; d = dictionary(wheels,names)
d = dictionary (double --> string) with 3 entries: 1 --> "Unicycle" 2 --> "Bicycle" 3 --> "Tricycle"
Use values
to return an array containing the values stored in the dictionary.
v = values(d)
v = 3x1 string
"Unicycle"
"Bicycle"
"Tricycle"
Return Values of Dictionary as Cell Array
Create a dictionary containing three key-value pairs that map numbers to strings.
names = ["Unicycle" "Bicycle" "Tricyle"]; wheels = [1 2 3]; d = dictionary(wheels,names)
d = dictionary (double --> string) with 3 entries: 1 --> "Unicycle" 2 --> "Bicycle" 3 --> "Tricyle"
Use values
to return an array containing the values stored in the dictionary as a cell array.
v = values(d,"cell")
v=3×1 cell array
{["Unicycle"]}
{["Bicycle" ]}
{["Tricyle" ]}
Input Arguments
d
— Dictionary
dictionary
object
Dictionary, specified as a dictionary
object. If d
is unconfigured, values
throws
an error.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
For code generation, you must use the
"cell"
argument.The code generator does not treat a dictionary as a constant, even if the dictionary is constant at code generation time. This means that the
values
function does not return a constant. You cannot pass the output of thevalues
function to a function that requires constant inputs. You cannot use the output of thevalues
function for operations that require constants, such as indexing into a heterogeneous cell array. The code generator also cannot perform optimizations that depend on constants, such as constant folding, on the output of thevalues
function.
For additional considerations that apply when generating C/C++ code for MATLAB® dictionaries, see Dictionary Limitations for Code Generation (MATLAB Coder).
Version History
Introduced in R2022bR2024b: Code generation support
You can generate C/C++ code for the dictionary values
function.
See Also
dictionary
| configureDictionary
| insert
| lookup
| remove
| entries
| keys
| types
| numEntries
| isConfigured
| isKey
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)