主要内容

PreLookup Index Search (Obsolete)

First stage of high-performance constant or linear interpolation that performs index search and interval fraction calculation for input on breakpoint set

Library

Lookup Tables (until R2006a)

  • PreLookup Index Search (Obsolete) block

Description

Note

The PreLookup Index Search block is obsolete. This block was removed from the Lookup Tables library in R2006b and replaced with the Prelookup block. However, existing models that contain the PreLookup Index Search block continue to work for backward compatibility.

Use the Prelookup block in new models. Consider using the upgradeadvisor function to replace PreLookup Index Search with Prelookup in existing models. See Programmatically Analyze and Upgrade Model.

Among other enhancements, the Prelookup block provides support for fixed-point data types, consistency checking, and more efficient code generation.

The PreLookup Index Search block is intended for use with the Interpolation (n-D) Using PreLookup (Obsolete) block. The PreLookup Index Search block calculates the index and interval fraction that specifies how its input value relates to the breakpoint data set. You feed the resulting (index, fraction) pair into an Interpolation (n-D) Using PreLookup block to interpolate an n-dimensional table. This combination of blocks performs the equivalent operation that a single instance of the n-D Lookup Table block performs. But by using these blocks instead, you can potentially increase the simulation performance of models that use many interpolation blocks.

To use this block, you must define a set of breakpoint values. Typically, this breakpoint data set corresponds to one dimension of a Table data parameter in an Interpolation (n-D) Using PreLookup block. The block generates a pair of outputs for each input value by calculating:

  • The index of the breakpoint set element that is less than or equal to the input value and forms an interval containing the input

  • The resulting fractional value that is a number 0 ≤ f < 1, representing the input value's normalized position on the breakpoint interval between the index and the next index value for in-range input

For example, if the breakpoint data set is

[ 0 5 10 20 50 100 ]

and the input value u is 55, the (index, fraction) pair is (4, 0.1), denoted respectively as k and f on the block. The index value is zero-based.

Note

The interval fraction can be negative or greater than 1 for out-of-range input. See the documentation for the Process out of range input block parameter for more information.

Data Type Support

The PreLookup Index Search block accepts signals of types double or single, but for any given block the inputs must all be of the same type. The Breakpoint data parameter must be of the same type as the inputs. The output data type is set to the input data type.

Parameters

Breakpoint data

The set of numbers to search. Specify a strictly monotonically increasing vector that contains two or more elements.

Index search method

Select Evenly Spaced Points, Linear Search, or Binary Search (the default). Each search method has speed advantages in different circumstances:

  • For evenly spaced breakpoint sets (for example, 10, 20, 30, and so on), you achieve optimal speed by selecting Evenly Spaced Points to calculate table indices.

  • For unevenly spaced breakpoint sets, follow these guidelines:

    • If input signals do not vary much between time steps, selecting Linear Search with Begin index search using previous index result produces the best performance.

    • If input signals jump more than one or two table intervals per time step, selecting Binary Search produces the best performance.

A suboptimal choice of index search method can lead to slow performance of models that rely heavily on lookup tables.

Begin index search using previous index result

Select this check box when you want the block to start its search using the index found on the previous time step. For inputs that change slowly with respect to the interval size, you can realize a large performance gain.

Output only the index

If you do not use this block to feed an Interpolation (n-D) Using PreLookup block, you can drop the interval fraction output. The resulting index value output is an int32 or uint32 value.

Process out of range input

Specifies how to handle out-of-range input. Options include:

  • Clip to Range

    If the input is less than the first breakpoint, return the index of the first breakpoint (for example, 0) and 0 for the interval fraction. If the input is greater than the last breakpoint, return the index of the next-to-last breakpoint and 1 for the interval fraction.

    Suppose that the range is [1 2 3] and you select this check box. If the input is 0.5, the block returns [0 0]; if the input is 3.5, the block returns [1 1].

  • Linear Extrapolation

    If the input is less than the first breakpoint, return the index of the first breakpoint and an interval fraction representing the linear distance from the input to the first breakpoint. If the input is greater than the last breakpoint, return the index of the next-to-last breakpoint and an interval fraction that represents the linear distance from the next-to-last breakpoint to the input.

    Suppose that the range is [1 2 3] and you select this check box. If the input is 0.5, the block returns [0 -0.5]; if the input is 3.5, the block returns [1 1.5].

Action for out of range input

Specifies whether to produce a warning or error message when the input is out of range. Options include:

  • None — the default, no warning or error message

  • Warning — display a warning message in the MATLAB® Command Window and continue the simulation

  • Error — halt the simulation and display an error message in the Simulation Diagnostics Viewer

Characteristics

Direct Feedthrough

Yes

Sample Time

Inherited from driving blocks

Scalar Expansion

Yes

Dimensionalized

Yes

Zero-Crossing Detection

No