5.0

5.0 | 1 rating Rate this file 19 downloads (last 30 days) File Size: 3.35 KB File ID: #19647

dict

by Doug Harriman

 

20 Apr 2008 (Updated 29 Apr 2008)

Code covered by BSD License  

General purpose data storage object

Download Now | Watch this File

File Information
Description

DICT is a general purpose data storage object similar to the DICT object in Python. Data is stored as key/value pairs. Keys and values can be any Matlab data type.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
lookupTable

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Requires the new class support in Matlab 2008a.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
25 Apr 2008 Dimitri Shvorob

What are the advantages compared to built-in (and accessible from most Matlab versions) java.util.Hashtable?

28 Apr 2008 Doug Harriman

The only advantage that I can see is that dict has a more natural Matlab interface. In my experience, accessing Java objects is not intuitive to those not experienced with programming Java. With a cleaner Matlab wrapping interface, the Java implementation would likely be superior.

06 Oct 2008 Doug Harriman

After looking at the java.util.Hashtable object, there is one major flaw with that solution. The java hashtable seems to only be able to store object types that are also implemented in java. For Matlab object types defined by the user, the Java hashtable throws an error. The pure Matlab implementation can store any Matlab object type that can be put into a cell array. It can also use any Matlab object type as a key.

14 Apr 2009 M MA

excellent submission
I wonder why matlab doesn't have built-in dictionaries

Please login to add a comment or rating.
Updates
23 Apr 2008

Fixed bug where error was caused if attempting to look up a key that did not exist. Now return empty matrix.

29 Apr 2008

Slight performance optimization. Added method to rename keys.

Tag Activity for this File
Tag Applied By Date/Time
dict Doug Harriman 22 Oct 2008 09:58:30
data storage Doug Harriman 22 Oct 2008 09:58:30
general Doug Harriman 22 Oct 2008 09:58:30
utilities Doug Harriman 22 Oct 2008 09:58:30
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com