entries - Key-value pairs of dictionary - MATLAB (original) (raw)

Main Content

Key-value pairs of dictionary

Since R2022b

Syntax

Description

`E` = entries([d](#mw%5F820daf04-84cc-4e51-84ca-ac2dc2d5b1e1%5Fsep%5Fmw%5F6b2c4725-2753-4b6a-805b-39686bdc1868)) returns a table containing the key-value pairs of the specified dictionary. Entries are returned in the order in which the entries were added to the dictionary.

example

`E` = entries([d](#mw%5F820daf04-84cc-4e51-84ca-ac2dc2d5b1e1%5Fsep%5Fmw%5F6b2c4725-2753-4b6a-805b-39686bdc1868),[format](#mw%5F17e62208-304f-434f-b01c-985fc37566a0))specifies the output format as a table or a structure. For example,entries(d,"struct") returns a structure containing the key-value pairs of d. Use this option for data types that are not compatible with tables.

example

Examples

collapse all

Create a dictionary containing several key-value pairs.

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 entries to return a table containing the entries stored in d.

E=3×2 table Key Value
___ __________

 1     "Unicycle"
 2     "Bicycle" 
 3     "Tricyle" 

Create a dictionary containing several key-value pairs.

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 entries and specify the output format as "struct" to return a struct array containing the entries stored in d.

E=3×1 struct array with fields: Key Value

Input Arguments

collapse all

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

Output format, specified as one of these values:

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 entries function.