MATLAB: How to create an empty Map container with a ‘KeyType’ other than the default ‘char’ in MATLAB 7.7 (R2008b)

containers.mapMATLAB

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

Best Answer

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)