Dictionaries of Hashtables in MATLAB?

조회 수: 52 (최근 30일)
Philip
Philip 2011년 11월 13일
답변: Mike Croucher 2022년 9월 15일
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!

채택된 답변

Walter Roberson
Walter Roberson 2011년 11월 13일
편집: John Kelly 2015년 2월 26일
  댓글 수: 3
Philip
Philip 2011년 11월 14일
(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 2011년 11월 14일
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!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Mike Croucher
Mike Croucher 2022년 9월 15일
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)

카테고리

Help CenterFile Exchange에서 Dictionaries에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by