| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
d = size(M)
d = size(M, dim)
[d1, d2, ..., dn] = size(M)
d = size(M) returns the number of key-value pairs in dimensions 1 and 2 of map M. Output d is a two-element row vector [n,1], where n is the number of key-value pairs.
d = size(M, dim) returns the number of key-value pairs if dim is 1, and otherwise returns 1.
[d1, d2, ..., dn] = size(M) returns [n, 1, ..., 1] where n is the number of key-value pairs in map M.
Read more about Map Containers in the MATLAB Programming Fundamentals documentation.
Create a Map object containing the names of several US states and the capital city of each:
US_Capitals = containers.Map( ...
{'Arizona', 'Nebraska', 'Nevada', 'New York', ...
'Georgia', 'Alaska', 'Vermont', 'Oregon'}, ...
{'Phoenix', 'Lincoln', 'Carson City', 'Albany', ...
'Atlanta', 'Juneau', 'Montpelier', 'Salem'})
Get the dimensions of the Map object array:
size(US_Capitals)
ans =
8 1
Use the map to find the capital of one of these states:
state = 'Georgia';
sprintf(' The capital of %s is %s', ...
state, US_Capitals(state))
ans =
The capital of Georgia is Atlantacontainers.Map, keys(Map), values(Map), length(Map), isKey(Map), remove(Map), handle
![]() | size | size (serial) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |