Lookup Table Optimizer
Optimize existing lookup table or approximate function with lookup table
Use the Lookup Table Optimizer app to obtain an optimized (memory-efficient) lookup table.
Using this app, you can:
Approximate an existing Simulink® block, including Subsystem blocks and math function blocks
Approximate a MATLAB® handle
Approximate a curve fit object
You can choose to return the optimized lookup table as a Simulink block or as a MATLAB function.
The optimizer supports any combination of floating-point and fixed-point data types. The original input and output data types can be kept or changed as desired. To minimize memory used, the optimizer selects the data types of breakpoints and table data as well as the number and spacing of breakpoints.
Open the Lookup Table Optimizer App
Simulink toolstrip: On the Apps tab, under Code Generation, click the app icon.
In a Simulink model with a Lookup Table block, select the Lookup Table block. In the Lookup Table tab, select Lookup Table Optimizer.
Source — Source for memory-efficient LUT
Simulink block or subsystem (default) | MATLAB function handle | curve fit object
Select the source for memory-efficient LUT:
Simulink block or subsystem — Simulink block or subsystem to approximate, or lookup table block to optimize, for example, 1-D Lookup Table or n-D Lookup Table. If you specify one of the lookup table blocks, the app generates an optimized lookup table.
MATLAB function handle — MATLAB function handle to approximate with a lookup table. Function handles must be on the MATLAB search path, or approximation fails.
Fitted curve — Curve fit
cfit(Curve Fitting Toolbox) object from the base workspace to approximate. For a list of library models to approximate, see List of Library Models for Curve and Surface Fitting (Curve Fitting Toolbox).
The process of generating a lookup table approximation is faster for a function handle than for a subsystem. If a subsystem can be represented by a function handle, approximating the function handle is faster.
Output Error Tolerance — Tolerance of difference between original and approximation
Specify the maximum tolerance of the
Relative difference between the original output value and
the output value of the approximation.
Allowed Word Lengths — Word lengths permitted in lookup table approximation
[8 16 32] (default) | vector of integers
Specify the word lengths, in bits, that can be used in the lookup table approximation based on your intended hardware. For example, if you intend to target an embedded processor, you can restrict the data types in your lookup table to native types. The word lengths must be between 1 and 128.
LUT Specification — Options for optimized lookup table
Breakpoint specification |
Saturate to output type |
AUTOSAR Compliant |
Explore Half |
HDL Optimized |
Specify options to use for the optimized lookup table.
When an input falls between breakpoint values, the lookup table interpolates the output value using neighboring breakpoints.
Spacing of breakpoint data.
For more information on how breakpoint specification can affect performance, see Effects of Spacing on Speed, Error, and Memory Usage.
Saturate to output type
Whether to automatically saturate the range of the output of the function to approximate to the range of the output data type.
Whether the generated lookup table is AUTOSAR compliant. When this
option is set to
This option is not supported when the
Whether to allow the optimizer to explore half-precision data types for table data and breakpoints.
Whether to generate an HDL-optimized approximation. When this
option is set to
To generate an HDL-optimized
approximation, the function to approximate must be one-dimensional and
How the app outputs the optimized lookup table.
The Simulink block and MATLAB function lookup table approximations generated by the Lookup Table Optimizer may not be exactly numerically equivalent. However, both solution forms are guaranteed to meet all constraints specified in the optimization problem.
Settings — Optimization options
Max time |
Max memory usage (bytes) |
On curve table values |
Specify additional optimization options.
Maximum amount of time for the approximation to run, specified in seconds as a scalar number. The approximation runs until it reaches the time specified, finds an ideal solution, or reaches another stopping criterion.
Max memory usage (bytes)
The maximum amount of memory the generated lookup table can use, in bytes, specified as a scalar integer.
On curve table values
Whether to constrain table values to the quantized output of the
function being approximated. When you set this option to
Whether to run iterations of the optimization in parallel. Running
iterations in parallel requires a Parallel Computing Toolbox™ license. If you do not have a Parallel Computing Toolbox, or if you specify
This option is not supported when the
Lookup table objects and breakpoint objects are not supported in a model mask workspace.
Functions and function handles that you approximate must meet these criteria:
The function must be time-invariant.
The function must operate element-wise, meaning for each input there is one output.
The function must not contain states.
For more information, see Vectorization.
Infinite Upper and Lower Input Bounds
When object to approximate specifies infinite input ranges and the input type is non-floating-point, the software infers upper and lower ranges during the approximation based on the range of the input data type. The resulting lookup table solution specifies the bounds that the algorithm used during the approximation, not the originally specified infinite bounds.
Upper and Lower Input Bounds and Input Data Type Range
specified for an input fall outside the range of the specified
Type, the algorithm uses the range of the data type specified by
Desired Data Type for the approximation.
In cases where the
Breakpoint specification option is set to
EvenSpacing but the specified
Maximum values of the
input is equal to the range of the
Desired Data Type, the
algorithm does not attempt to find a solution using
Version HistoryIntroduced in R2018a
R2022b: Support for curve fitting objects
The Lookup Table Optimizer app now supports curve fitting
cfit (Curve Fitting Toolbox) objects as valid inputs for approximation.
R2022a: Improved memory reduction for 1-D and flat interpolation
The Lookup Table Optimizer has an improved algorithm for lookup table value and breakpoint optimization for one-dimensional functions with flat interpolation. This enhancement can enable improved memory reduction of the optimized lookup table and faster completion of the lookup table optimization process.
This improvement applies when the function to approximate is one-dimensional and all of these options are specified:
Interpolationis set to
Breakpoint specificationis set to
On curve table valuesis set to
R2021b: Generate an optimized lookup table approximation as a MATLAB function
Use the Lookup Table Optimizer app to generate an optimized lookup table approximation as a MATLAB function. The generated MATLAB function is editable and supports C/C++ code generation using MATLAB Coder™.
R2021a: Generate optimized one-dimensional lookup tables for HDL applications
Use the Lookup Table Optimizer app to generate a subsystem consisting of a prelookup step followed by interpolation that functions as a lookup table with explicit pipelining to generate efficient HDL code.
R2021a: Lookup table optimization support for functions with scalar inputs
Previously, the Lookup Table Optimizer required that functions and function handles to approximate were vectorized, meaning that for each input, there is exactly one output. Starting in R2021a, lookup table optimization fully supports approximation of Simulink blocks and subsystems that only allow scalar inputs.
R2021a: Improved lookup table value optimization
The Lookup Table Optimizer has an improved algorithm for lookup table value
optimization for the
methods when off-curve table values are allowed. This enhancement can enable faster
completion of the lookup table optimization process and improved memory reduction of the
optimized lookup table.
R2021a: Stop optimization in Lookup Table Optimizer app
You can now stop the optimization solver in the Lookup Table Optimizer before the optimization search is complete. The app will choose the best solution found at the time the Stop button is clicked and display the solution in the app.
R2020b: Explore half precision in optimized lookup tables
Specify whether the optimization process explores half-precision data types for table data and breakpoint values.
R2020a: Iteratively redesign lookup tables in your model
The Lookup Table Optimizer now replaces blocks being approximated by a lookup table with a variant subsystem containing the function approximation. The variant subsystem enables you to return to the original function and perform the optimization again using different optimization settings and constraints.
R2020a: Parallelized lookup table optimization
Specify whether to run iterations of the optimization in parallel. Running iterations in
parallel requires a Parallel Computing Toolbox license. If you do not have a Parallel Computing Toolbox license, or if you specify
False, the iterations
run in serial.
R2019b: Allow off-curve table values in optimized lookup tables
You can now generate an optimized lookup table with off-curve table values.
In previous releases, the optimization required table values to match the quantized output values of the original function being approximated. By allowing off-curve table values, you may be able to reduce the memory of the lookup table while maintaining the same error tolerances, or maintain the same memory while reducing the error tolerances.