Main Content

values

Values of dictionary

    Description

    example

    v = values(d) returns an array containing the values of the specified dictionary.

    example

    v = values(d,"cell") optionally return the values as a cell array.

    Examples

    collapse all

    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.

    v = values(d)
    v = 3x1 string
        "Unicycle"
        "Bicycle"
        "Tricyle"
    
    

    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

    collapse all

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

    Version History

    Introduced in R2022b