Skip to Main Content Skip to Search
Product Documentation

Characteristics of Lookup Table Data

Sizes of Breakpoint Data Sets and Table Data

The following constraints apply to the sizes of breakpoint data sets and table data associated with lookup table blocks:

To illustrate the second constraint, consider the following vectors of input and output values that create the relationship in the plot.

Vector of input values:   [-3 -2 -1  0 1 2 3]
Vector of output values:  [-3 -1  0 -1 0 1 3]

In this example, the input and output data are the same size (1-by-7), making the data consistently dimensioned for a 1-D lookup table.

The following input and output values define the 2-D lookup table that is graphically shown.

Row index input values:    [1 2 3]
Column index input values: [1 2 3 4]
Table data:                [11 12 13 14; 21 22 23 24; 31 32 33 34]

In this example, the sizes of the vectors representing the row and column indices are 1-by-3 and 1-by-4, respectively. Consequently, the output table must be of size 3-by-4 for consistent dimensions.

Monotonicity of Breakpoint Data Sets

The first stage of a table lookup operation involves relating inputs to the breakpoint data sets. The search algorithm requires that input breakpoint sets be monotonically increasing, that is, each successive element is equal to or greater than its preceding element. For example, the vector

A = [0  0.5  1  1.9  2  2  2  2.1  3]

repeats the value 2 while all other elements are increasingly larger than their predecessors; hence, A is monotonically increasing.

For lookup tables with data types other than double or single, the search algorithm requires an additional constraint due to quantization effects. In such cases, the input breakpoint data sets must be strictly monotonically increasing, that is, each successive element must be greater than its preceding element. Consider the vector

B = [0  0.5  1  1.9  2  2.1  2.17  3]

in which each successive element is greater than its preceding element, making B strictly monotonically increasing.

Representation of Discontinuities in Lookup Tables

You can represent discontinuities in lookup tables that have monotonically increasing breakpoint data sets. To create a discontinuity, repeat an input value in the breakpoint data set with different output values in the table data. For example, these vectors of input (x) and output (y) values associated with a 1-D lookup table create the step transitions depicted in the plot that follows.

Vector of input values:   [-2 -1 -1  0 0 1 1 2]
Vector of output values:  [-1 -1 -2 -2 2 2 1 1]

This example has discontinuities at x = –1, 0, and +1.

When there are two output values for a given input value, the block chooses the output according to these rules:

When there are three points specified at the origin, the block generates the output associated with the middle point. The following example demonstrates this special rule.

Vector of input values:   [-2 -1 -1  0 0 0 1 1 2]
Vector of output values:  [-1 -1 -2 -2 1 2 2 1 1]

In this example, three points define the discontinuity at the origin. When the input is 0, y is 1, the value of the middle point.

You can apply this same method to create discontinuities in breakpoint data sets associated with multidimensional lookup tables.

Formulation of Evenly Spaced Breakpoints

You can represent evenly spaced breakpoints in a data set by using one of these methods.

FormulationExampleWhen to Use This Formulation
[first_value:spacing:last_value][10:10:200]The lookup table does not use double or single.
first_value + spacing * [0:(last_value-first_value)/spacing]1 + (0.02 * [0:450])The lookup table uses double or single.

Because floating-point data types cannot precisely represent some numbers, the second formulation works better for double and single. For example, use 1 + (0.02 * [0:450]) instead of [1:0.02:10]. For a list of lookup table blocks that support evenly spaced breakpoints, see Summary of Lookup Table Block Features.

Among other advantages, evenly spaced breakpoints can make the generated code division-free and reduce memory usage. For more information, see:

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS