In some cases, the dimensions of your data set dictate which of the lookup table blocks is right for your application. If you are approximating a one-dimensional function, consider using either the 1-D Lookup Table or Lookup Table Dynamic block. If you are approximating a two-dimensional function, consider the 2-D Lookup Table block. Blocks such as the n-D Lookup Table and Direct Lookup Table (n-D) allow you to approximate a function of N variables.
The numeric and data types of your data set influence the decision
of which lookup table block is most appropriate. Although all lookup
table blocks support real numbers, the Direct Lookup Table
(n-D), 1-D Lookup Table, 2-D Lookup
Table, and n-D Lookup Table blocks also support
complex table data. All lookup table blocks support integer and fixed-point
data in addition to
For the Direct Lookup Table (n-D) block, fixed-point types are supported for the table data, output port, and optional table input port.
The desired accuracy and smoothness of the data returned by a lookup table determine which of the blocks you should use. Most blocks provide options to perform interpolation and extrapolation, improving the accuracy of values that fall between or outside of the table data, respectively. For instance, the Lookup Table Dynamic block performs linear interpolation and extrapolation, while the n-D Lookup Table block performs either linear or cubic spline interpolation and extrapolation. In contrast, the Direct Lookup Table (n-D) block performs table lookups without any interpolation or extrapolation. You can achieve a mix of interpolation and extrapolation methods by using the Prelookup block with the Interpolation Using Prelookup block.
The dynamics of the lookup table inputs impact which of the lookup table blocks is ideal for your application. The blocks use a variety of index search methods to relate the lookup table inputs to the table's breakpoint data sets. Most of the lookup table blocks offer a binary search algorithm, which performs well if the inputs change significantly from one time step to the next. The 1-D Lookup Table, 2-D Lookup Table, n-D Lookup Table, and Prelookup blocks offer a linear search algorithm. Using this algorithm with the option that resumes searching from the previous result performs well if the inputs change slowly. Some lookup table blocks also provide a search algorithm that works best for breakpoint data sets composed of evenly spaced breakpoints. You can achieve a mix of index search methods by using the Prelookup block with the Interpolation Using Prelookup block.
When the efficiency with which lookup tables operate is important, consider using the Prelookup block with the Interpolation Using Prelookup block. These blocks separate the table lookup process into two components — an index search that relates inputs to the table data, followed by an interpolation and extrapolation stage that computes outputs. These blocks enable you to perform a single index search and then reuse the results to look up data in multiple tables. Also, the Interpolation Using Prelookup block can perform sub-table selection, where the block interpolates a portion of the table data instead of the entire table. For example, if your 3-D table data constitutes a stack of 2-D tables to be interpolated, you can specify a selection port input to select one or more of the 2-D tables from the stack for interpolation. A full 3-D interpolation has 7 sub-interpolations but a 2-D interpolation requires only 3 sub-interpolations. As a result, significant speed improvements are possible when some dimensions of a table are used for data stacking and not intended for interpolation. These features make table lookup operations more efficient, reducing computational effort and simulation time.
Use the following table to identify features that correspond to particular lookup table blocks, then select the block that best meets your requirements.
|Feature||1-D Lookup Table||2-D Lookup Table||Lookup Table Dynamic||n-D Lookup Table||Direct Lookup Table (n-D)||Prelookup||Interp. Using Prelookup|
|Numeric & Data Type Support|
|Index Search Methods|
|Evenly spaced points||•||•||•||•||•|
|Start at previous index||•||•||•||•|
|Dynamic breakpoint data||•|
|Dynamic table data||•||•||•|
|Input range checking||•||•||•||•||•||•|