remove - Remove dictionary entries - MATLAB (original) (raw)

Main Content

Remove dictionary entries

Since R2023b

Syntax

Description

`d2` = remove([d1](#mw%5Ff999582a-dc67-48e1-968b-e83d5e22bd7a),[key](#mw%5F48247526-bbec-4d3f-845a-53c0a28963fa)) removes the entry corresponding to key from dictionary,d1.

d = remove(d,key) is equivalent to d(key) = [ ].

example

Examples

collapse all

Create a dictionary containing several key-value pairs.

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"

Remove the entry corresponding to 2.

d =

dictionary (double ⟼ string) with 2 entries:

1 ⟼ "Unicycle"
3 ⟼ "Tricycle"

Create a dictionary containing several key-value pairs.

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"

Remove the entries corresponding to [2,3].

d =

dictionary (double ⟼ string) with 1 entry:

1 ⟼ "Unicycle"

Input Arguments

collapse all

Input dictionary, specified as a dictionary object.

Key set, specified as an array. The data type of key must match or be convertible to the data type of keys in d1.

Extended Capabilities

Version History

Introduced in R2023b

expand all

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