MATLAB: How to implement a 2-D or n-D dynamic lookup table block in Simulink 7.8 ( R2011b)

2dblockdynamiclookupsimulinktable

Simulink -> Lookup Tables library has a 1-D Dynamic Lookup Table. How do I implement the same functionality for a 2-D or n-D Lookup tables?

Best Answer

This can be done by connecting 'n' number of "Prelookup" blocks to an "Interpolation Using Prelookup" block.
Please find attached a library model 'Dynamic_2D_Lookup_Table.mdl' that contains a Dynamic 2-D Lookup Table block and a test model 'TS_Dynamic_2D_Lookup.mdl' that uses this block.
'Look Under Mask' to view the implementation of the custom library block. You can extend the same functionality to create 3-D and 4-D dynamic lookup table blocks. Change the 'Number of Table Dimensions' parameter of the Interpolation using Prelookup' block to 3 or 4 and use the corresponding number of 'Pre-Lookup' blocks.
Inside the custom library block, the 'Table Data Source' parameter of the 'Interpolation using Prelookup' block is set to 'From Input'. It is this feature that allows a dynamic implementation of the lookup table. Please note that this feature is not available in R2010a and earlier releases. Using the library block in these versions will crash MATLAB. There are no workaround for the earlier versions.