Skip to Main Content Skip to Search
Accelerating the pace of engineering and science

How can I create an empty Map container with a 'KeyType' other than the default 'char' in MATLAB 7.7 (R2008b)?


Date Last Modified: Wednesday, May 19, 2010
Solution ID:   1-71KD5H
Product:   MATLAB
Reported in Release:   R2008b
Fixed in Release:   R2010a
Platform:   All Platforms
Operating System:   All OS
 

Subject:

How can I create an empty Map container with a 'KeyType' other than the default 'char' in MATLAB 7.7 (R2008b)?

Problem Description:

I would like to be able to create an empty Map container with a 'KeyType' other than the default 'char' type.

Solution:

This enhancement has been incorporated in Release 2010a (R2010a). For previous product releases, read below for any possible workarounds:

The ability to create empty Map containers with 'KeyType' other than the default is not available in MATLAB.

To work around this, one can create a non-empty container with a desired 'KeyType' and then remove the values, as follows:
m = containers.Map(uint32(1), 1) % KeyType is uint32.
remove(m,1)

Please provide feedback to help us improve this Solution
Contact support