Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Interpolation Using Prelookup - Use precalculated index and fraction values to accelerate approximation of N-dimensional function

Library

Lookup Tables

Description

Comparison with the Lookup Table (n-D) Block

The Interpolation Using Prelookup block works best with the Prelookup block. The Prelookup block calculates the index and interval fraction that specifies how its input value relates to the breakpoint data set. You feed the resulting index and fraction values into an Interpolation Using Prelookup block to interpolate an n-dimensional table. This combination of blocks performs the same operation that a single instance of the Lookup Table (n-D) block performs. However, the Prelookup and Interpolation Using Prelookup blocks offer greater flexibility that can provide more efficient simulation and code generation.

How The Block Works with a Prelookup Block

To use this block, you must define a set of output values as the Table data parameter. Typically, these table values correspond to the breakpoint data sets specified in Prelookup blocks. The Interpolation Using Prelookup block generates output by looking up or estimating table values based on index and interval fraction values fed from Prelookup blocks. The index and interval fraction appear on the Interpolation Using Prelookup block as k and f, respectively.

If the inputs...The Interpolation Using Prelookup block...
Match the values of indices in breakpoint data setsOutputs the table value at the intersection of the row, column, and higher dimension breakpoints
Do not match the values of indices in breakpoint data sets, but are within rangeInterpolates appropriate table values, using the Interpolation method you select
Do not match the values of indices in breakpoint data sets, and are out of rangeExtrapolates the output value, using the Extrapolation method you select

How The Block Interpolates a Subset of Table Data

You can use the Number of sub-table selection dimensions parameter to specify that interpolation occur only on a subset of the table data. To activate this interpolation mode, set this parameter to a positive integer. This value defines the number of dimensions to select, starting from the highest dimension of table data. Therefore, the value must be less than or equal to the Number of table dimensions.

Suppose that you have 3-D table data in your Interpolation Using Prelookup block. The following behavior applies.

Number of Selection DimensionsAction by the BlockBlock Appearance
0Interpolates the entire table and does not activate subtable selectionDoes not change
1Interpolates the first two dimensions and selects the third dimensionDisplays an input port with the label sel1 that you use to select and interpolate 2-D tables
2Interpolates the first dimension and selects the second and third dimensionsDisplays two input ports with the labels sel1 and sel2 that you use to select and interpolate 1-D tables

For an example of interpolating a subset of table data, type sldemo_bpcheck at the MATLAB command prompt.

Data Type Support

The Interpolation Using Prelookup block accepts real signals of any numeric data type supported by Simulink software, except Boolean. The Interpolation Using Prelookup block supports fixed-point data types for signals, table data, and intermediate results.

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

The Main pane of the Interpolation Using Prelookup block dialog box appears as follows:

Number of table dimensions

The number of dimensions that the Table data parameter must have. This value defines the number of independent variables for the table and the number of inputs to the block. Enter an integer between 1 and 30 into this field.

Table data

The table of output values. During simulation, the matrix size must match the dimensions defined by the Number of table dimensions parameter. Note that during block diagram editing, you can enter an empty matrix (specified as []) or an undefined workspace variable as the Table data parameter. Use this behavior to postpone specifying a correctly-dimensioned matrix for the Table data parameter and continue editing the block diagram. For information about how to construct multidimensional arrays in MATLAB software, see Multidimensional Arrays in the MATLAB online documentation.

Click the Edit button to open the Lookup Table Editor (see Lookup Table Editor in the Simulink documentation).

Interpolation method

None - Flat or Linear. See Interpolation Methods in the Simulink documentation for more information.

Extrapolation method

None - Clip or Linear. See Extrapolation Methods in the Simulink documentation for more information. The Extrapolation method parameter is visible only if you select Linear as the Interpolation method parameter.

    Note   The Interpolation Using Prelookup block does not support Linear extrapolation if its input or output signals specify integer or fixed-point data types.

Action for out-of-range input

Specifies whether to produce a warning or error message if 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

Check index in generated code (Real-Time Workshop license required)

Specifies whether Real-Time Workshop generated code checks the validity of index values that feed this block.

This check box has no effect on generated code if one of the following is true:

  • The Prelookup block feeds index values to the Interpolation Using Prelookup block.

    Because index values from the Prelookup block are always valid, no check code is necessary.

  • The data type of the input signal restricts the data to valid index values.

    For example, unsigned integer data types guarantee nonnegative index values. Therefore, unsigned inputs do not require check code for negative values.

Valid index input may reach last index

Specifies how the block inputs for index (k) and interval fraction (f) access the last elements of the n-dimensional table in Table data. Index values are zero-based.

If this check box is...The block returns the value of the last element in a dimension of its table when...
Selected
  • k indexes the last table element in the corresponding dimension

  • f is 0

Not selected
  • k indexes the next-to-last table element in the corresponding dimension

  • f is 1

This check box is visible only when:

  • Interpolation method is Linear.

  • Extrapolation method is None - Clip.

    Tip   If you select Valid index input may reach last index for an Interpolation Using Prelookup block, you must also select Use last breakpoint for input at or above upper limit for all Prelookup blocks that feed it. This action allows the blocks to use the same indexing convention when accessing the last elements of their Breakpoint data and Table data parameters.

Number of sub-table selection dimensions

Specifies the number of dimensions of the subtable that the block uses to compute the output. Follow these rules:

  • To enable subtable selection, enter a positive integer.

    This integer must be less than or equal to the Number of table dimensions.

  • To disable subtable selection, enter 0 (the default) to interpolate the entire table.

For more information, see How The Block Interpolates a Subset of Table Data.

Sample time

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See How to Specify the Sample Time in the Simulink documentation for more information.

The Signal Attributes pane of the Interpolation Using Prelookup block dialog box appears as follows:

Output minimum

Specify the minimum value that the block should output. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:

Output maximum

Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:

Output data type

Specify the output data type. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Inherit via back propagation

  • The name of a built-in data type, for example, single

  • The name of a data type object, for example, a Simulink.NumericType object

  • An expression that evaluates to a data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.

See Specifying Block Output Data Types for more information.

Lock data type settings against changes by the fixed-point tools

Select to lock all data type settings of this block against changes by the Fixed-Point Tool and the Fixed-Point Advisor. For more information, see Fixed-Point Tool and Fixed-Point Advisor in the Simulink Fixed Point documentation.

Integer rounding mode

Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink Fixed Point User's Guide.

Block parameters such as Table data are always rounded to the nearest representable value. To control the rounding of a block parameter, enter an expression using a MATLAB rounding function into the mask field.

Saturate on integer overflow

Select to have overflows saturate. Otherwise, overflows wrap.

When you select this check box, saturation applies to every internal operation on the block, not just the output or result. In general, the code generation process can detect when overflow is not possible, in which case, no saturation code is necessary.

The Table Attributes pane of the Interpolation Using Prelookup block dialog box appears as follows:

Table minimum

Specify the minimum value for table data. The default value, [], is equivalent to -Inf.

Table maximum

Specify the maximum value for table data. The default value, [], is equivalent to Inf.

Table data type

Specify the table data type. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Same as output

  • The name of a built-in data type, for example, single

  • The name of a data type object, for example, a Simulink.NumericType object

  • An expression that evaluates to a data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Table data type parameter.

    Tip   Specify a table data type different from the output data type for these cases:

    • Lower memory requirement for storing table data that uses a smaller type than the output signal

    • Sharing of prescaled table data between two Interpolation Using Prelookup blocks with different output data types

    • Sharing of custom storage table data in Real-Time Workshop generated code for blocks with different output data types

The Intermediate Attributes pane of the Interpolation Using Prelookup block dialog box appears as follows:

Intermediate results data type

Specify the intermediate results data type. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Same as output

  • The name of a built-in data type, for example, single

  • The name of a data type object, for example, a Simulink.NumericType object

  • An expression that evaluates to a data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Intermediate results data type parameter.

    Tip   Use this parameter to specify higher precision for internal computations than for table data or output data.

Examples

See Examples for Prelookup and Interpolation Blocks in the Simulink documentation.

Characteristics

Direct Feedthrough

Yes

Sample Time

Specified in the Sample time parameter

Scalar Expansion

Yes

Dimensionalized

Yes

Zero-Crossing Detection

No

See Also

Prelookup

  


Related Products & Applications

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

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