values - Values of dictionary - MATLAB (original) (raw)

Main Content

Values of dictionary

Since R2022b

Syntax

Description

`v` = values([d](#mw%5F31c4bc89-5d1f-481f-bbf4-55d628f5c4f6%5Fsep%5Fmw%5F6b2c4725-2753-4b6a-805b-39686bdc1868)) returns an array containing the values of the specified dictionary. Values are returned in the order in which the entries were added to the dictionary.

example

`v` = values([d](#mw%5F31c4bc89-5d1f-481f-bbf4-55d628f5c4f6%5Fsep%5Fmw%5F6b2c4725-2753-4b6a-805b-39686bdc1868),"cell") optionally return the values as a cell array.

example

Examples

collapse all

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 = 3×1 string "Unicycle" "Bicycle" "Tricycle"

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=3×1 cell array {["Unicycle"]} {["Bicycle" ]} {["Tricyle" ]}

Input Arguments

collapse all

Dictionary, specified as a dictionary object. If d is unconfigured, values throws an error.

Extended Capabilities

expand all

Usage notes and limitations:

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 R2022b

expand all

You can generate C/C++ code for the dictionary values function.