length - Number of key-value pairs in Map object - MATLAB (original) (raw)

Main Content

Number of key-value pairs in Map object

Syntax

Description

Note

dictionary is recommended overcontainers.Map because it accepts more data types as keys and values and provides better performance. (since R2022b)

L = length([M](#d126e993534)) returns the number of key-value pairs in the input Map object.length(M) is equivalent to size(M,1) and to the property M.Count.

example

Examples

collapse all

Create a Map object.

months = {'Jan','Feb','Mar','Apr'}; rainfall = [327.2 368.2 197.6 178.4]; M = containers.Map(months,rainfall)

M = Map with properties:

    Count: 4
  KeyType: char
ValueType: double

Return the number of key-value pairs that it contains.

Input Arguments

Version History

Introduced in R2008b