Main Content

length

Number of key-value pairs in Map object

Description

example

L = length(M) 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.

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.

L = length(M)
L = 4

Input Arguments

collapse all

Input Map object.

Introduced in R2008b