Main Content

remove

Remove dictionary entries

Since R2023b

    Description

    example

    d2 = remove(d1,key) removes the entry corresponding to key from dictionary, d1.

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

    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 = remove(d,2)
    d =
    
      dictionary (double --> string) with 2 entries:
    
        1 --> "Unicycle"
        3 --> "Tricycle"
    

    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.

    Version History

    Introduced in R2023b