A lookup table block uses an array of data to map input values to output values, approximating a mathematical function. Given input values, Simulink® performs a "lookup" operation to retrieve the corresponding output values from the table. If the lookup table does not define the input values, the block estimates the output values based on nearby table values.
The following example illustrates a one-dimensional lookup table that approximates the function y = x3. The lookup table defines its output (y) data discretely over the input (x) range [-3, 3]. The following table and graph illustrate the input/output relationship:
An input of -2 enables the table to look up and retrieve the corresponding output value (-8). Likewise, the lookup table outputs 27 in response to an input of 3.
When the lookup table block encounters an input that does not match any of the table's x values, it can interpolate or extrapolate the answer. For instance, the lookup table does not define an input value of -1.5; however, the block can linearly interpolate the nearest data points (-2, -8) and (-1, -1) to estimate and return a value of -4.5.
Similarly, although the lookup table does not include data for x values beyond the range of [-3, 3], the block can extrapolate values using a pair of data points at either end of the table. Given an input value of 4, the lookup table block linearly extrapolates the nearest data points (2, 8) and (3, 27) to estimate an output value of 46.
Since table lookups and simple estimations can be faster than mathematical function evaluations, using lookup table blocks might result in speed gains when simulating a model. Consider using lookup tables in lieu of mathematical function evaluations when:
An analytical expression is expensive to compute.
No analytical expression exists, but the relationship has been determined empirically.
Simulink provides a broad assortment of lookup table blocks, each geared for a particular type of application. The sections that follow outline the different offerings, suggest how to choose the lookup table best suited to your application, and explain how to interact with the various lookup table blocks.