Dictionaries of Hashtables in MATLAB?

45 visualizaciones (últimos 30 días)
Philip
Philip el 13 de Nov. de 2011
Respondida: Mike Croucher el 15 de Sept. de 2022
Hi all,
Is there a way to create a hash table or dictionary in MATLAB such that I can retrieve a set of values based on a key?
I also need to append more entries to the end of the list, given a key. I tried importing a hashtable from java.util.Hashtable, but the "add" method overwrites the current entries if a key already exists...
Thanks for all your help!

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Nov. de 2011
Editada: John Kelly el 26 de Feb. de 2015
  3 comentarios
Philip
Philip el 14 de Nov. de 2011
(I need to collect the keys and values inside a loop, so I don't know them beforehand - this means unfortunately I cannot enter all the data at once.)
Philip
Philip el 14 de Nov. de 2011
To answer my own question there, it seems the solution for adding values without overwriting the previous entries is:
mapName('key_string') = [mapName('key_string') [1 2 3]];
Thanks for your suggestion. I think this will work!

Iniciar sesión para comentar.

Más respuestas (1)

Mike Croucher
Mike Croucher el 15 de Sept. de 2022
Reviving this thread in 2022 because R2022b contains a new dictionary data type. A tutorial-like introduction at An introduction to dictionaries (associative arrays) in MATLAB » The MATLAB Blog - MATLAB & Simulink (mathworks.com)

Categorías

Más información sobre Dictionaries en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by