Simulink Reference Previous page   Next Page
Lookup Table

Approximate a one-dimensional function using the specified lookup method

Library

Lookup Tables

Description

The Lookup 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:

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:

The Lookup Table 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.

To avoid parameter saturation errors, the automatic scaling script autofixexp employs a special rule for the Lookup Table block. autofixexp modifies the scaling by using the output lookup values in addition to the logged minimum and maximum simulation values. This prevents the data from being saturated to different values. The lookup values are given by the Vector of output values parameter (the YDataPoints variable).

Data Type Support

The Lookup Table block supports all data types supported by Simulink, including fixed-point data types.

For a discussion on the data types supported by Simulink, refer to Data Types Supported by Simulink in the Using Simulink documentation.

Parameters and Dialog Box

The Main pane of the Lookup Table block dialog appears as follows:

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.
The Vector of input values parameter is converted from doubles to the input data type offline using round-to-nearest and saturation.
Click the Edit button to invoke the Lookup Table Editor.
Vector of output values
Specify the vector of output values. The output values vector must be the same size as the input values vector.
The Vector of output values parameter is converted from doubles to the output data type offline using round-to-nearest and saturation.
Look-up method
Specify the lookup method. See Description for a discussion of the options for this parameter.
Sample time (-1 for inherited)
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See Specifying Sample Time in the online documentation for more information.

The Data types pane of the Lookup Table block dialog appears as follows:

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 you select Specify via dialog for the Output data type mode parameter.
Output scaling value
Set the output scaling using binary point-only or [Slope Bias] scaling. This parameter is only visible if you select Specify via dialog for the Output data type mode parameter.
Lock output scaling against changes by the autoscaling tool
Select to lock scaling of outputs. This parameter is only visible if you select Specify via dialog for the Output data type mode parameter.
Round integer calculations toward
Select the rounding mode for fixed-point look-up table calculations that occur during simulation or execution of code generated from the model.
Note that this option does not affect rounding of values of block parameters, such as Vector of output values. Simulink rounds such values to the nearest representable integer value. To control the rounding of a block parameter, enter an expression using a MATLAB rounding function into the parameter's edit field on the block dialog box.
Saturate on integer overflow
Select to have overflows saturate.

Examples

Suppose the Lookup 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.

Lookup Method
Input
Output
Comment
Interpolation-Extrapolation
1.4
2.156
N/A
5.2
83.59
N/A
Interpolation-Use End Values
1.4
2.156
N/A
5.2
74.2
The value for sinh(5.0) was used.
Use Input Above
1.4
3.627
The value for sinh(2.0) was used.
5.2
74.2
The value for sinh(5.0) was used.
Use Input Below
1.4
1.175
The value for sinh(1.0) was used.
-5.2
-74.2
The value for sinh(-5.0) was used.
Use Input Nearest
1.4
1.175
The value for sinh(1.0) was used.

Characteristics

Direct Feedthrough
Yes
Sample Time
Inherited from driving block
Scalar Expansion
No
Dimensionalized
Yes
Zero Crossing
No

See Also

Lookup Table (2-D), Lookup Table (n-D)


Previous page  Logical Operator Lookup Table (2-D) Next page

© 1994-2005 The MathWorks, Inc.