From: Eric on
I'm wondering if anybody else has run into this problem. I have code where I use containers.Map objects to keep track of arrays by their names. This no longer seems to work in Matlab R2010a. For example, the following works fine in R2009b:

>> A = containers.Map('hello',[1 2]); >> A = containers.Map('hello',[1 2]); A('hello')

ans =

1 2

However, in Matlab R2010a:

>> A = containers.Map('hello',[1 2])
??? Error using ==> containers.Map
Specified value type does not match the type expected for this container.

According to the manual's Map Containers page: "The values stored in a Map can be of any type. This includes arrays of numeric values, structures, cells, strings, objects, or other Maps."

Does anybody know if this is a bug or if the syntax has changed? What is the correct syntax for the line that worked in R2009b?

Thanks,
Eric
From: Eric on
My example of the code that works in R2009b should read:

>> A = containers.Map('hello',[1 2]); A('hello')

ans =

1 2
From: Eric on
Okay, I'm going to stop playing with this now, but...

If I replace [1 2] with [W1 W2] where W1 and W2 are instantiations of a class I've written, the containers.Map works fine. It apparently only fails for arrays of numbers (not objects). Weird.

-Eric
From: Bruno Luong on
Well weird indeed. A workaround may be put the curly brackets around:

A = containers.Map({'hello'},{[2 1]})

Bruno
From: Bruno Luong on
This syntax also works:

A = containers.Map('hello',[2 1],'uniformValues', false)

Bruno