No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

2.0 | 1 rating Rate this file 3 Downloads (last 30 days) File Size: 2.49 KB File ID: #19381 Version: 1.0



Dan Cohn (view profile)


30 Mar 2008 (Updated )

Creates a lookup table for a collection of key/value pairs

| Watch this File

File Information

Creates a lookup table for a collection of key/value pairs. Keys can be ANY data-type (although indexing over function handles might produce unexpected/incorrect behavior)
weatherStruct = struct('clouds','rain','windy','cold');
obj = weatherObject(weatherStruct,...);
tbl = lookupTable('today''s weather', weatherStruct,obj,'found weather obj',0.0123,'random data here');
A = tbl('today''s weather')
  = weatherStruct
A = tbl(obj)
  = 'found weather obj'
A = tbl(0.0123)
  = 'random data here'
k = tbl.key(1) %equal to first element of key
  = 'today''s weather'
v = tbl.value(2) %equal to second element of value
  = 'found weather obj'

key = tbl.contents('-key')
    = {'today''s weather',obj,123}

value = tbl.contents('-value')
= {weatherStruct,'found weather obj','random data here'}


This file inspired Dict.

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
08 Aug 2012 Fa Fa

Fa Fa (view profile)

Hi,i like to understand this function in matlab,
f = @(x) (sum(x(:)) >= 2);
lut = makelut(f,2);

the Question:how he get the result from 0 to 15;
1 etc;

Thank for help

Comment only
25 Apr 2008 Dimitri Shvorob

Check out this submission:

and search Matlab doc for


Comment only
25 Apr 2008 Dimitri Shvorob

5 minutes wasted trying to understand how it works.. The example in 'help' uses a user-defined class and so, of course, doesn't run; was the goal to make things more complicated? Finally, extra points for shadowing Simulink's 'lookuptable'.

Contact us