When I use the following code to retrieve the Key which belongs to a specified Value of a Containers Map array, I receive an error message:
Reproduction Steps
%%Create Containers Map
ticketMap = containers.Map(... {'jan', 'feb', 'march'}, ... {10, 20, 30});% ticketMap = containers.Map( ...
% {'Georgia', 'Alaska', 'Vermont', 'Oregon'}, ...
% {'Atlanta', 'Juneau', 'Montpelier', 'Salem'})
%%Show keys
ticketMap.keyskeys(ticketMap)%%Show values
ticketMap.valuesvalues(ticketMap)%%Retrieve specified value wrt defined key
testkey = 'feb';msg_value = ticketMap.values({testkey})% or
msg_value = values(ticketMap,{testkey})%%Retrieve specified Key wrt defined Value, not possible...
testvalue = 30;msg_key = ticketMap.values({testvalue})% ormsg_key = values(ticketMap,{testvalue})
%%%BEGIN ERROR MESSAGE%%%
??? Error using ==> values
Specified key type does not match the type expected for this container.
%%%END ERROR MESSAGE%%%
Best Answer