LookupTable Block
1-D lookup table with linear interpolation. Maps input values to output values using breakpoints and corresponding table data.
Open LookupTable in BlockWerk →# Lookup Table
1-D lookup table with linear interpolation. Maps input values to output values using a set of breakpoints and corresponding table data.
Mathematical Model
Given breakpoints x₀ < x₁ < ... < xₙ and table values y₀, y₁, ..., yₙ:
For xᵢ ≤ x ≤ xᵢ₊₁:
output = yᵢ + (yᵢ₊₁ - yᵢ) · (x - xᵢ) / (xᵢ₊₁ - xᵢ)
Extrapolation:
- clip: output = y₀ if x < x₀, yₙ if x > xₙ
- linear: extend interpolation slope from nearest interval
Parameters
| Parameter | Type | Default | Description | | ------------- | ------ | --------- | ------------------------------------------------------------------------------------- | | breakpoints | text | "0 1 2 3" | Space-separated list of input breakpoints (must be monotonically increasing) | | tableData | text | "0 1 4 9" | Space-separated list of output values (must match breakpoints length) | | extrapolation | select | clip | Behaviour outside breakpoint range: clip (hold endpoints) or linear (extrapolate) |
Ports
- In (input): Input value to look up
- Out (output): Interpolated output value
Behaviour
- Between breakpoints: linear interpolation
- At breakpoints: exact table value
- Outside range with
clip: returns first or last table value - Outside range with
linear: linearly extrapolates using the nearest two points
Remarks
- Breakpoints monotonic: Breakpoints must be strictly increasing; non-monotonic breakpoints produce undefined results
- Table size: Table data length must exactly match the breakpoints length
- Extrapolation — clip: Safer for most applications; prevents output from exceeding the defined range
- Extrapolation — linear: Useful when the trend beyond the last breakpoint is known to continue linearly
- Performance: O(log n) lookup via binary search; efficient even with thousands of breakpoints
Examples
With breakpoints 0 1 2 3 and table data 0 1 4 9:
- Input 0.5 → Output 0.5 (interpolated between 0 and 1)
- Input 1.5 → Output 2.5 (interpolated between 1 and 4)
- Input 5.0 with clip → Output 9 (clamped to last value)
- Input 5.0 with linear → Output 19 (extrapolated)