Lookup Table Optimizer
Optimize existing lookup table or approximate function with lookup table
Description
Use the Lookup Table Optimizer app to obtain an optimized (memoryefficient) 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 floatingpoint and fixedpoint 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.
Examples
Parameters
Source
— Source for memoryefficient LUT
Simulink block or subsystem (default)  MATLAB function handle  curve fit object
Select the source for memoryefficient LUT:
Simulink block or subsystem — Simulink block or subsystem to approximate, or lookup table block to optimize, for example, 1D Lookup Table or nD 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).
Tip
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
nonnegative scalar
Specify the maximum tolerance of the Absolute
and
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 65,535.
LUT Specification
— Options for optimized lookup table
Interpolation
 Breakpoint specification
 Saturate to output type
 AUTOSAR Compliant
 Explore Half
 HDL Optimized
 Solution Type
Specify options to use for the optimized lookup table.
Option  Description 

Interpolation  When an input falls between breakpoint values, the lookup table interpolates the output value using neighboring breakpoints.

Breakpoint specification  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. 
AUTOSAR Compliant  Whether the generated lookup table is AUTOSAR compliant. When this
option is set to
This option is not supported when the

Explore Half  Whether to allow the optimizer to explore halfprecision data types for table data and breakpoints. 
HDL Optimized  Whether to generate an HDLoptimized approximation. When this
option is set to To generate an HDLoptimized
approximation, the function to approximate must be onedimensional and

Solution Type  How the app outputs the optimized lookup table.
Note 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
 Use parallel
Specify additional optimization options.
Option  Description 

Max time  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. Default: 
Max memory usage (bytes)  The maximum amount of memory the generated lookup table can use, in bytes, specified as a scalar integer. Default:

On curve table values  Whether to constrain table values to the quantized output of the
function being approximated. When you set this option to
Default: 
Use parallel  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
Default:

Limitations
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 timeinvariant.
The function must operate elementwise, meaning for each input there is one output.
The function must not contain states.
For more information, see Vectorization.
Algorithms
Infinite Upper and Lower Input Bounds
When object to approximate specifies infinite input ranges and the input type is nonfloatingpoint, 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
If the Minimum
or Maximum
specified for an input fall outside the range of the specified Desired Data
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
Minimum
or 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
EvenPow2Spacing
.
Version History
Introduced in R2018aR2022b: 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 1D and flat interpolation
The Lookup Table Optimizer has an improved algorithm for lookup table value and breakpoint optimization for onedimensional 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 onedimensional and all of these options are specified:
Interpolation
is set toFlat
.Breakpoint specification
is set toExplicitValues
.On curve table values
is set toFalse
.
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 onedimensional 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 Flat
and Nearest
interpolation
methods when offcurve 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 halfprecision 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 offcurve table values in optimized lookup tables
You can now generate an optimized lookup table with offcurve table values.
In previous releases, the optimization required table values to match the quantized output values of the original function being approximated. By allowing offcurve 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.
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令：
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)