Code covered by the BSD License  

Highlights from
dict

5.0

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

dict

by Doug Harriman

 

20 Apr 2008 (Updated 29 Apr 2008)

General purpose data storage object

| 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
This submission has inspired the following:
Dictionary data structure

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
dict JT 26 Oct 2010 16:06:18
dict Diego Villamil 24 Jan 2012 13:50:18

Contact us at files@mathworks.com