Simulink Reference |

Approximate a one-dimensional function using the specified lookup method

**Library**

Simulink Look-Up Tables and Fixed-Point Blockset LookUp

**Description**

The Look-Up Table block computes an approximation to some function `y=f(x)`

given data vectors `x`

and `y`

.

The length of the `x`

and `y`

data vectors provided to this block must match. Also, the `x`

data vector must be strictly monotonically increasing after conversion to the input's fixed-point data type, except in the following case. If the input `x`

and the output signal are both either `single`

or `double`

, and if the lookup method is `Interpolation-Extrapolation`

, then `x`

may be monotonically increasing rather than strictly monotonically increasing. Note that due to quantization, the `x`

data vector may be strictly monotonic in doubles format, but not so after conversion to a fixed-point data type.

You define the table by specifying the **Vector of input values** parameter as a 1-by-n vector and the **Vector of output values** parameter as a 1-by-n vector. The block generates output based on the input values using one of these methods selected from the **Look-up method** parameter list:

`Interpolation-Extrapolation`

--This is the default method; it performs linear interpolation and extrapolation of the inputs.- If a value matches the block's input, the output is the corresponding element in the output vector.
- If no value matches the block's input, then the block performs linear interpolation between the two appropriate elements of the table to determine an output value. If the block input is less than the first or greater than the last input vector element, then the block extrapolates using the first two or last two points.
`Interpolation-Use End Values`

--This method performs linear interpolation as described above but does not extrapolate outside the end points of the input vector. Instead, the end-point values are used.`Use Input Nearest`

--This method does not interpolate or extrapolate. Instead, the element in`x`

nearest the current input is found. The corresponding element in`y`

is then used as the output.`Use Input Below`

--This method does not interpolate or extrapolate. Instead, the element in`x`

nearest and below the current input is found. The corresponding element in`y`

is then used as the output. If there is no element in`x`

below the current input, then the nearest element is found.`Use Input Above`

--This method does not interpolate or extrapolate. Instead, the element in`x`

nearest and above the current input is found. The corresponding element in`y`

is then used as the output. If there is no element in`x`

above the current input, then the nearest element is found.

To create a table with step transitions, repeat an input value with different output values. For example, these input and output parameter values create the input/output relationship described by the plot that follows:

This example has three step discontinuities: at *u* = -1, 0, and +1.

When there are two points at a given input value, the block generates output according to these rules:

- When the input signal
*u*is less than zero, the output is the value connected with the point first encountered when moving away from the origin in a negative direction. In this example, when*u*is -1,*y*is -2, marked with a solid circle. - When
*u*is greater than zero, the output is the value connected with the point first encountered when moving away from the origin in a positive direction. In this example, when*u*is 1,*y*is 2, marked with a solid circle. - When
*u*is at the origin and there are two output values specified for zero input, the actual output is their average. In this example, if there were no point at*u*= 0 and*y*= 1, the output would be 0, the average of the two points at*u*=0. If there are three points at zero, the block generates the output associated with the middle point. In this example, the output at the origin is 1.

The Look-Up Table block icon displays a graph of the input vector versus the output vector. When a parameter is changed on the block's dialog box, the graph is automatically redrawn when you click the **Apply** or **Close** button.

When the **Show additional parameters** check box is selected, some of the parameters that become visible are common to many blocks. For a detailed description of these parameters, refer to Block Parameters in the Fixed-Point Blockset documentation.

To avoid parameter saturation errors, the automatic scaling script `autofixexp`

employs a special rule for the Look-Up Table block. `autofixexp`

modifies the scaling by using the output look-up values in addition to the logged minimum and maximum simulation values. This prevents the data from being saturated to different values. The look-up values are given by the **Vector of output values** parameter (the `YDataPoints`

variable).

**Parameters and Dialog Box**

**Vector of input values**- Specify the vector of input values. The input values vector must be the same size as the output values vector. Also, the input values vector must be strictly monotonically increasing after conversion to the input's fixed-point data type, except in the following case. If the input values vector and the output signal are both either
`single`

or`double`

, and if the lookup method is`Interpolation-Extrapolation`

, then the input values vector may be monotonically increasing rather than strictly monotonically increasing. Note that due to quantization, the input values vector may be strictly monotonic in doubles format, but not so after conversion to a fixed-point data type. **Vector of output values**- Specify the vector of output values. The output values vector must be the same size as the input values vector.
**Show additional parameters**- If selected, additional parameters specific to implementation of the block become visible as shown.

**Look-up method**- Specify the lookup method. See Description for a discussion of the options for this parameter.
**Output data type mode**- You can set the output signal to a built-in data type from this drop-down list, or you can choose the output data type and scaling to be the same as the input. Alternatively, you can choose to inherit the output data type and scaling by backpropagation. Lastly, if you choose
`Specify via dialog`

, the**Output data type**,**Output scaling value**, and**Lock output scaling against changes by the autoscaling tool**parameters become visible. **Output data type**- Specify any data type, including fixed-point data types. This parameter is only visible if
`Specify via dialog`

is selected for the**Output data type mode**parameter. **Output scaling value**- Set the output scaling using radix point-only or [Slope Bias] scaling. This parameter is only visible if
`Specify via dialog`

is selected for the**Output data type mode**parameter. **Lock output scaling against changes by the autoscaling tool**- If selected, scaling of outputs is locked. This parameter is only visible if
`Specify via dialog`

is selected for the**Output data type mode**parameter. **Round integer calculations toward**- Select the rounding mode for the fixed-point output.
**Saturate on integer overflow**- If selected, overflows saturate.

**Conversions and Operations**

The **Vector of input values** parameter is converted from doubles to the input data type. The **Vector of output values** parameter is converted from doubles to the output data type. Both conversion are performed offline using round-to-nearest and saturation. Refer to Parameter Conversions in the Fixed-Point Blockset documentation for more information about parameter conversions.

**Examples**

Suppose the Look-Up Table block in the above model is configured to use a vector of input values given by `[-5:5]`

, and a vector of output values given by `sinh([-5:5])`

. The following results are generated.

**Characteristics**

Dimensionalized | Yes |

Direct Feedthrough | Yes |

Sample Time | Inherited from driving block |

Scalar Expansion | No |

Zero Crossing | No |

**See Also**

Look-Up Table (2-D), Look-Up Table (n-D)

Logical Operator | Look-Up Table (2-D) |