Main Content

numEntries

Number of key-value pairs in dictionary

    Description

    example

    n = numEntries(d) returns the number of key-value pairs stored in the specified dictionary. If d is an unconfigured dictionary, then numEntries returns 0.

    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 numEntries to determine how many key-value pairs are stored in d.

    n = numEntries(d)
    n = 3
    

    Input Arguments

    collapse all

    Dictionary, specified as a dictionary object.

    Version History

    Introduced in R2022b