The following constraints apply to the sizes of breakpoint data sets and table data associated with lookup table blocks:
The memory limitations of your system constrain the overall size of a lookup table.
Lookup tables must use consistent dimensions so that the overall size of the table data reflects the size of each breakpoint data set.
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.
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.
Note:
Although a breakpoint data set is strictly monotonic in |
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:
If the input signal is less than zero, the block returns the output value associated with the last occurrence of the input value in the breakpoint data set. In this example, if the input is –1, y is –2, marked with a solid circle.
If the input signal is greater than zero, the block returns the output value associated with the first occurrence of the input value in the breakpoint data set. In this example, if the input is 1, y is 2, marked with a solid circle.
If the input signal is zero and there are two output values specified at the origin, the block returns the average of those output values. In this example, if the input is 0, y is 0, the average of the two output values –2 and 2 specified at x = 0.
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.
You can represent evenly spaced breakpoints in a data set by using one of these methods.
Formulation | Example | When 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:
fixpt_evenspace_cleanup
in
the Simulink^{®} documentation
Effects of Spacing on Speed, Error, and Memory Usage in the Fixed-Point Designer™ documentation
Identify questionable fixed-point operations in the Simulink Coder™ documentation
Tip
Do not use the MATLAB^{®} |