Hash tables in MATLAB - Statistical Machine Learning and Visualization

Upon a little reflection, it occured to me that MATLAB does in fact have the ability for a rudimentary native hash-table:

terms = { 'price'  'cents'  'govern'  'billion'  'company'  'state'  'economy'  'stock' };
ids   = num2cell(1:length(terms));
dict  = reshape({terms{:};ids{:}},2,[]);
dict  = struct(dict{:});

dict.('cents')  % my two cents!

Of course one could also use java:

dict = java.util.Hashtable;
dict.put('key',[1 2 3]);
dict.get('key')
dict.containsKey('key')

Hash tables in MATLAB - Statistical Machine Learning and Visualization.

Rating: 5.9/10 (42 votes cast)

Related posts:

  1. Venture Capital’s New Green Machine from wsj YEAR-END REVIEW OF MARKETS & FINANCE     Venture...

One Response to “Hash tables in MATLAB - Statistical Machine Learning and Visualization”

  1. 1
    GS Says:
    July 23rd, 2010 at 8:36 pm

    Or if you have one of the later versions of matlab you could try the Containers.Map class.

    see this on matlab site:
    http://www.mathworks.com/acces.....o5e-1.html

    Rating: 0.0/5 (0 votes cast)

Leave a Reply

Preview:

Tags:
Separate individual tags by commas