0
0
SimulinkHow-ToBeginner · 3 min read

How to Use Lookup Table in Simulink: Simple Guide

In Simulink, use the Lookup Table block to map input values to output values based on predefined data points. You configure the table by specifying breakpoints and corresponding output data, allowing Simulink to interpolate outputs for inputs during simulation.
📐

Syntax

The Lookup Table block syntax involves three main parts:

  • Breakpoints: These are the input values where output data points are defined.
  • Table data: The output values corresponding to each breakpoint.
  • Interpolation method: Defines how Simulink calculates output for inputs between breakpoints (e.g., linear, nearest).

You set these parameters in the block's dialog box or via block parameters programmatically.

simulink
Lookup Table block parameters:
- Breakpoints: [x1, x2, x3, ...]
- Table data: [y1, y2, y3, ...]
- Interpolation: 'linear' or 'nearest'

Example:
Breakpoints: [0, 5, 10]
Table data: [0, 25, 100]
Interpolation: 'linear'
💻

Example

This example shows how to create a simple 1-D lookup table in Simulink that maps input values to output values using linear interpolation.

Input values are breakpoints [0, 5, 10], and output values are [0, 25, 100]. The block outputs interpolated values for inputs between these points.

plaintext
1. Open Simulink and create a new model.
2. Drag a <code>Lookup Table</code> block from the <code>Simulink > Lookup Tables</code> library.
3. Double-click the block and set:
   - Breakpoints: [0 5 10]
   - Table data: [0 25 100]
   - Interpolation method: linear
4. Add a <code>Constant</code> block with value 7 and connect it to the Lookup Table input.
5. Add a <code>Scope</code> block to see the output.
6. Connect the Lookup Table output to the Scope.
7. Run the simulation.

The output will be 55 because 7 is between 5 and 10, and linear interpolation calculates the output accordingly.
Output
Scope output shows a constant value of 55 during simulation.
⚠️

Common Pitfalls

  • Incorrect breakpoints: Breakpoints must be strictly increasing; otherwise, Simulink will give an error.
  • Mismatch in table data size: The number of table data points must match the number of breakpoints.
  • Interpolation method: Choosing 'nearest' may cause unexpected jumps in output values.
  • Input out of range: Inputs outside the breakpoint range use extrapolation or the nearest breakpoint value, which may not be desired.
simulink
Wrong way:
Breakpoints: [0 5 5 10]  % Not strictly increasing
Table data: [0 25 50 100]

Right way:
Breakpoints: [0 5 10]
Table data: [0 25 100]
📊

Quick Reference

ParameterDescriptionNotes
BreakpointsInput values where outputs are definedMust be strictly increasing
Table dataOutput values corresponding to breakpointsSame length as breakpoints
InterpolationMethod to estimate outputs between breakpoints'linear' or 'nearest' common options
ExtrapolationBehavior for inputs outside breakpointsCan be set to clip or extrapolate

Key Takeaways

Use the Lookup Table block to map inputs to outputs based on defined breakpoints and data.
Ensure breakpoints are strictly increasing and table data matches in size.
Choose interpolation method carefully to get smooth or step outputs.
Inputs outside breakpoint range may be clipped or extrapolated depending on settings.
Test your lookup table with sample inputs to verify correct output behavior.