No BSD License  

2.0

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

lookupTable

by

 

30 Mar 2008 (Updated )

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

| Watch this File

File Information
Description

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)
 
Examples:
 
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'}

Acknowledgements

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

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;
0
0
0
1
0
1 etc;

Thank for help

25 Apr 2008 Dimitri Shvorob

Check out this submission:

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=6514&objectType=file

and search Matlab doc for

java.util.hashtable

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