2-D Lookup Table
MathThe LookupTable2D block maps two independent input signals ( and ) to an output value using bilinear or bicubic spline interpolation over a rectangular two-dimensional grid. It models complex bivariate nonlinear functions where physical behavior depends simultaneously on two operational variablesβsuch as electric motor efficiency maps (), internal combustion engine fuel maps (), compressor pressure ratio characteristics, and aerodynamic drag polars.
In the Property Editor, all three series ( column headers, row headers, and matrix cells) are edited together in a 2D Excel-style matrix spreadsheet (2D Matrix (Y \ X β Z)) paired with a live multi-slice LUT plot preview (z = f(x, y)). You can add or remove columns (+X) and rows (+Y), and save or load the entire 2D surface directly via CSV Import / Export (lut2d_data.csv), supporting comma (,), semicolon (;), and tab (\t) delimiters.
Mathematical Model
Given strictly increasing grid coordinates and strictly increasing coordinates , the grid values are defined across the rectangular mesh in row-major order.
For input coordinates falling within cell , normalized local coordinates and are computed as:
Bilinear interpolation calculates the interpolated surface value :
When extrapolation is set to clip, input coordinates outside the grid bounds are clamped to the boundary ranges and prior to surface evaluation:
When set to linear, the block projects the bilinear tangent plane of the nearest outer bounding cell.
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| → In | in1 |
x | number | Required |
| → In | in2 |
y | number | Required |
| ← Out | out |
Out | number | Output |
Parameters
| Parameters | Label | Type | Default | Description |
|---|---|---|---|---|
xBreakpoints |
2D Lookup Table (X / Y / Z) | table-2d | 0 1 |
|
yBreakpoints |
Y Breakpoints | text | 0 1 |
|
tableData |
Table Data (row-major) | text | 0 1 1 2 |
|
interpolation |
Interpolation | select | linear |
|
extrapolation |
Extrapolation | select | linear |
Usage Examples
Example 1: Permanent Magnet Synchronous Motor (PMSM) Efficiency Map
In an electric powertrain model, motor efficiency varies nonlinearly with both shaft speed and output torque. Entering column headers 500 1500 3000 6000 (RPM), row headers 10 50 100 150 (Nm), and the efficiency cells in the 2D matrix editor (or importing from a test-bench CSV) allows the block to evaluate continuous drive efficiency for any operating point during regenerative braking and acceleration cycles.
Example 2: Engine Fuel Injection Mass Calibration Map
Modeling mass fuel injection per cylinder stroke as a function of intake manifold absolute pressure (MAP, -axis in kPa: 20 40 60 80 100) and engine speed (-axis in RPM: 1000 2000 3000 4000 5000). Using extrapolation = clip ensures that unexpected intake pressure spikes during turbocharger lag do not extrapolate into uncalibrated, dangerously lean or rich fueling states.
Remarks & Best Practices
- 2D Matrix Spreadsheet & Live Preview: Double-clicking the block opens a corner-indexed
Y \ Xspreadsheet where the top header row defines breakpoints, the left header column defines breakpoints, and interior cells define , alongside a live uPlot chart showing one colored curve per row. - CSV Save & Load (Import / Export & Excel Paste): Click Export CSV to save the 2D grid as
lut2d_data.csv(with blank top-left corner cell, breakpoints in row 1, and each subsequent row starting with its breakpoint followed by values), Import CSV to load a 2D table from Excel/CSV, or paste a 2D grid selection directly from Excel (Ctrl+V). - Row-Major Memory Order: Under the hood,
tableDatais stored in row-major order: index sequence increments through all column values before advancing to the subsequent row. - Strict Coordinate Monotonicity: Both
xBreakpointsandyBreakpointsmust be strictly monotonically increasing. - Independent Binary Coordinate Search: The simulation engine performs independent binary bisections along each axis, ensuring rapid real-time performance even with dense surface meshes.
Frequently Asked Questions (FAQ)
Q: How is bilinear interpolation computed across a 2D grid in real-time simulation?
For input coordinates falling in cell , normalized fractions and are calculated. The output is . Monotonic breakpoint ordering enables binary search, guaranteeing constant-time evaluation in 60fps WebAssembly simulation.
Related Components
- LookupTable: One-dimensional lookup table with interactive 2-column spreadsheet and linear/cubic spline interpolation.
- Product: Multiplies two independent dynamic signals.
- MathFunction: Standard mathematical functions (, , ).