Black FridayUpgrade your career this Black Friday. Get up to ₹60,000 Scholarship on IIT programsUp to ₹60K Black Friday Scholarship52 seats leftOffer ends Fri, 27 Nov, 11:59 pm IST.

Black Friday Scholarship – IIT Jammu & IIT Roorkee

The best Black Friday deal isn't a gadget. It's your next career move.

Get up to ₹60,000 Black Friday Scholarship on our PG programs with IIT Jammu and iHUB DivyaSampark, IIT Roorkee. IIT certification, 12 live sessions with IIT faculty and 100% placement assistance.

Only 52 seats left. Offer ends Fri, 27 Nov, 11:59 pm IST

3,905 engineers placed since 2019 · 1,276 hiring companies

By submitting you agree to our Terms and Privacy Policy.

Your free demo class is requested

Browse courses

How to Use a Lookup Table in Simulink: Step-by-Step with Examples

Build a 1-D Lookup Table in Simulink step by step: every dialog setting explained, why breakpoints must increase, a verified thermistor example, Clip vs Linear extrapolation and Simulink.LookupTable objects.

How to Use a Lookup Table in Simulink: Step-by-Step with Examples

To use a lookup table in Simulink, drag the 1-D Lookup Table block from the Simulink / Lookup Tables library into your model. Enter your input values under Breakpoints and the matching outputs under Table data. Choose the interpolation and extrapolation methods on the Algorithm tab, then connect a signal to the input and run. The block then returns an interpolated output at every time step.

In short

  • The 1-D Lookup Table block (MathWorks documentation, R2026b) has three tabs: Table and Breakpoints, Algorithm and Data Types. Out of the box it uses Linear point-slope interpolation, Linear extrapolation and Binary search.
  • Breakpoints must be strictly increasing. A thermistor's resistance falls as it heats up, so you flip both vectors before you enter them. The table data itself may go down.
  • For a 10 kΩ NTC thermistor tabulated every 10 °C, an 11-point table indexed by resistance is off by up to 0.73 °C. Index the same 11 points by the divider voltage and the worst error drops to 0.38 °C. Index them by ln(resistance) and it drops to 0.09 °C.
  • Clip and Linear extrapolation give different answers outside the table. At 40 kΩ (about −3.2 °C), Clip returns 0 °C and Linear returns −4.74 °C.

This is the hands-on companion to our explainer What is a lookup table?, which covers the theory: interpolation maths, error bounds and 2-D tables. Here you build two working models and set every important option in the block dialog. Skill-Lync computed every number below with a short Python script kept alongside the post, so you can re-run them in MATLAB with interp1 and get the same answers.

Where is the lookup table block in Simulink?

Open the Library Browser and go to Simulink, then Lookup Tables. The block you want for one input is 1-D Lookup Table. You can also click on the empty canvas, type "1-D Lookup Table" and press Enter. The same library holds the 2-D and n-D Lookup Table blocks, Prelookup, Interpolation Using Prelookup and Direct Lookup Table (n-D).

Drop a fresh 1-D Lookup Table into a model and it already holds data: Breakpoints [-5:5] and Table data tanh([-5:5]). That is MathWorks' default, a coarse 11-point tanh curve. Feed it 0.5 and it returns 0.3808, not the true tanh(0.5) of 0.4621, because 0.5 sits halfway between breakpoints 0 and 1 and the block draws a straight line between them. Replace the defaults with your own data before you trust any output.

How do you build a simple lookup table model? A step-by-step example

Start with a table you can check in your head: y = 2x. You will see exactly how the block treats inputs that fall on a breakpoint, between two breakpoints and beyond the end of the table.

Simulink model: a Repeating Sequence Stair block with values 6, 2.5 and 4 feeds a 1-D Lookup Table with breakpoints 0 to 10 and table data 2 times the breakpoints. A Scope shows 12, 5 and 8.
Three blocks are enough to see how the lookup table behaves at, between and beyond its breakpoints.
  1. Add a source. Place a Repeating Sequence Stair block (Simulink / Sources). Set Vector of output values to [6 2.5 4] and Sample time to 1.
  2. Add the table. Place a 1-D Lookup Table block. On the Table and Breakpoints tab, keep Number of table dimensions at 1, Data specification at Table and breakpoints and Breakpoints specification at Explicit values.
  3. Enter the data. Set Breakpoints to 0:2:10 and Table data to 2*(0:2:10). Both are six elements long, and they must match.
  4. Check the algorithm. On the Algorithm tab, leave Interpolation method at Linear point-slope and Extrapolation method at Linear.
  5. View the output. Connect a Scope, set the stop time to 10 s and run.

The Scope steps through 12, 5 and 8, then repeats. Inputs 6 and 4 land exactly on breakpoints, so the block returns the stored values. Input 2.5 falls between breakpoints 2 and 4, a quarter of the way along, so the block returns 4 + 0.25 × (8 − 4) = 5.

Now try an input of 12, beyond the last breakpoint. With Linear extrapolation the block extends the last segment and returns 24. Switch Extrapolation method to Clip and it returns 20, the last table value. Neither is wrong. Which one you want depends on whether the relationship really continues past your data.

What does each setting in the 1-D Lookup Table dialog do?

The Table and Breakpoints tab defines the data. The Algorithm tab decides how the block reads between and beyond your points. The Data Types tab matters only for fixed-point or embedded code. For most models you set the breakpoints, table data, interpolation and extrapolation, and leave the rest at its defaults.

Table and Breakpoints tab

SettingOptions (default first)What it does
Number of table dimensions1, 2, 3 … up to 30The block turns into a 2-D or n-D table when you raise it
Data specificationTable and breakpoints; Lookup table objectType the data in the dialog, or point to a Simulink.LookupTable object
Breakpoints specificationExplicit values; Even spacingEven spacing asks only for First point and Spacing
SourceDialog; Input portInput port lets the table data or breakpoints change while the simulation runs
Edit table and breakpointsButtonOpens the Lookup Table Editor to view and edit the data as a grid

Algorithm tab

SettingOptions (default first)When to change it
Interpolation methodLinear point-slope; Flat; Nearest; Linear Lagrange; Cubic spline; Akima splineFlat holds the value at the breakpoint below the input. Nearest jumps to the closest breakpoint. Splines give a smooth curve.
Extrapolation methodLinear; Clip; Cubic spline; Akima splineClip holds the end value. Spline extrapolation needs the matching spline interpolation.
Diagnostic for out-of-range inputNone; Warning; ErrorSet Error when an input outside the table means something has gone wrong
Index search methodBinary search; Linear search; Evenly spaced pointsEvenly spaced points is fastest but needs evenly spaced breakpoints
Begin index search using previous index resultOff; OnTurn it on, usually with Linear search, when the input changes slowly from step to step
Assume input is within rangeOff; OnRemoves range checks from generated code. It replaced "Remove protection against out-of-range input in generated code" in R2025a.

Two restrictions catch people out. Cubic spline interpolation works only on scalar signals. Akima spline doesn't support fixed-point data or Simulink.LookupTable objects.

How do you build a lookup table from sensor data? A thermistor example

Lookup tables earn their place when the relationship is curved and comes from a datasheet, not from a neat formula. A temperature sensor on an embedded board is the classic case. Here the input is the thermistor's resistance, and the output is temperature.

We use an illustrative 10 kΩ NTC thermistor with B = 3950 K and the Beta model, R = R25·eB(1/T − 1/T25), with T in kelvin and T25 = 298.15 K. The Beta model is a simplified Steinhart–Hart equation. On a real board, paste the R–T table from your part's datasheet straight into the block instead. Either way, you don't need to solve an equation at run time.

Tabulating every 10 °C from 0 to 100 °C gives 11 points: 33,621 Ω at 0 °C, 20,175 Ω at 10 °C, 12,535 Ω at 20 °C, 10,000 Ω at 25 °C (by definition) and down to 698 Ω at 100 °C.

Why do the breakpoints have to be flipped?

The block requires breakpoints that are strictly monotonically increasing. An NTC thermistor's resistance decreases as temperature rises, so resistance listed against rising temperature runs the wrong way. Flip both vectors together so resistance increases and temperature decreases. The table data may decrease; only the breakpoints must increase.

T   = 0:10:100;                                   % deg C
R   = 10e3 * exp(3950 * (1./(T + 273.15) - 1/298.15));  % ohm, Beta model
bpR = fliplr(R);    % Breakpoints: 698 ... 33621 ohm (increasing)
tbT = fliplr(T);    % Table data:  100 ... 0 deg C
interp1(bpR, tbT, 15e3)   % 16.77, the same value the block returns

Run that in MATLAB, then put bpR and tbT into the block's Breakpoints and Table data fields. Feed in a Constant of 15000. The block returns 16.77 °C. The true temperature at 15 kΩ is 16.15 °C, so this table reads 0.63 °C high at that point.

Temperature against thermistor resistance. The 11-point table closely follows the true Beta-model curve. At 15 kilo-ohm the table gives 16.77 C against a true 16.15 C. At 40 kilo-ohm, outside the table, Clip gives 0 C and Linear extrapolation gives -4.74 C against a true -3.24 C.
The table (blue) against the true curve (green). Past the coldest breakpoint the extrapolation setting decides the answer. Clip freezes at 0 °C, while Linear extrapolation overshoots the true −3.24 °C.

What happens when the sensor reads outside the table?

Suppose the board sits outdoors on a winter morning and the thermistor reads 40 kΩ, which is about −3.24 °C. That is beyond the 0 °C end of the table. Linear extrapolation extends the last segment and returns −4.74 °C, 1.5 °C too cold. Clip returns 0 °C, 3.24 °C too warm. In a real product, extend the table to the coldest temperature you need, then set Diagnostic for out-of-range input to Warning while testing, so a reading outside the table can't slip by unnoticed.

What should you use as the breakpoint input?

The input you index by matters as much as how many points you store. Linear interpolation is only accurate where the curve between breakpoints is nearly straight. Pick an input that makes the curve straighter and the same 11 points become far more accurate, with no extra memory.

Interpolation error across 0 to 100 C for an 11-point table. Indexed by resistance the worst error is 0.73 C, by divider voltage 0.38 C, and by the natural log of resistance 0.09 C.
The same 11 temperatures with three different breakpoint inputs. Each arch is one interval between breakpoints, where the straight line sags away from the curve.
Breakpoint inputWorst error, 0 to 100 °CWhat it costs
Resistance (Ω)0.73 °C (near 5 °C)You must compute R from the ADC reading first
Divider voltage: 10 kΩ from 3.3 V, thermistor to ground0.38 °C (near 85 °C)None, because this is what the ADC measures
ln(resistance)0.09 °CA Math Function (log) block before the table, which costs one logarithm per step

The ln(R) row works because, under the Beta model, 1/T is a straight line in ln(R). The only curvature left comes from converting 1/T back to T. For most boards the divider voltage is the practical choice, because the table reads the measured signal directly.

Explicit values or Even spacing?

Evenly spaced breakpoints let you pick the fastest index search, Evenly spaced points, which finds the index with no search at all. The catch is that you can't put the points where the curve bends. Spread evenly in voltage across 0 to 100 °C, the table needs 31 breakpoints to keep the worst error under 0.5 °C. The 11 unevenly spaced voltage points above already reach 0.38 °C. Binary search over 10 intervals takes only 4 comparisons, so on most targets the explicit table is the better trade.

How do you keep table data in a Simulink.LookupTable object?

When a table is used by several blocks or models, store it as a Simulink.LookupTable object rather than typing numbers into each block dialog. One object holds the table data and its breakpoints together, so they can't drift apart. Set the block's Data specification to Lookup table object and type the object's name in the Name field.

ntcLUT = Simulink.LookupTable;
ntcLUT.Table.Value          = tbT;      % 100 ... 0 deg C
ntcLUT.Breakpoints(1).Value = bpR;      % 698 ... 33621 ohm
ntcLUT.StructTypeInfo.Name  = 'ntcLUT_Type';

That follows MathWorks' own example for the object. In a team project, keep the object in a Simulink Data Dictionary rather than the base workspace, so it is versioned with the model. Our guide to the Simulink Data Dictionary (SLDD) shows how to create one, link it and migrate workspace variables into it.

What replaced the Lookup Table Dynamic block?

The 2022 version of this post used the Lookup Table Dynamic block, with breakpoints −5 to 5, table data sinh(−5:5) and an input of 1.4. With its nearest-point option the block returned sinh(1) = 1.1752. Since R2026b, MathWorks labels Lookup Table Dynamic "not recommended". To get the same behaviour today, use a 1-D Lookup Table and set the Source of its table data, and breakpoints if needed, to Input port.

The old example still shows why the interpolation method matters. At x = 1.4, Nearest and Flat both return 1.1752 and Linear point-slope returns 2.1559. The true sinh(1.4) is 1.9043. With integer breakpoints on a curve this steep, no setting is accurate. You need more breakpoints.

Frequently asked questions

Why does Simulink say my breakpoints must be monotonically increasing?

The block's index search assumes each breakpoint is larger than the one before, so it rejects repeated or decreasing values. This usually happens with sensors whose output falls as the input rises, such as NTC thermistors. Flip the breakpoints and the table data together with fliplr so the breakpoints increase, and remove any duplicate values.

How do I make a 2-D lookup table in Simulink?

Use the 2-D Lookup Table block, or set Number of table dimensions to 2. Breakpoints 1 index the rows and Breakpoints 2 index the columns, so the table data must be an M-by-N matrix. M must equal the length of Breakpoints 1 and N the length of Breakpoints 2. Get the orientation wrong and the sizes no longer match.

Which interpolation method should I use?

Start with the default, Linear point-slope. It is cheap, it never overshoots between points, and it generates simple code. Use Flat or Nearest only when the output really changes in steps, such as gear selection. Use Cubic or Akima spline when you need a smooth, differentiable output and the input is a scalar.

How do I check that my lookup table is correct?

Run a handful of inputs through MATLAB's interp1 with the same breakpoints and table data and compare them with the block's output. Test inputs on a breakpoint, between two breakpoints and outside the range. Then sweep the input across its full range and plot the error against the true curve, as in the thermistor example.

Can a lookup table be used in generated C code?

Yes. The block generates code like any other Simulink block, and MathWorks notes that tables are often faster than computing the function directly. Evenly spaced breakpoints let the code find the index without a division and use less memory, which suits small microcontrollers. Only tick Assume input is within range when the input truly cannot leave the table.

Lookup tables, Simulink models and embedded code are taught hands-on in Skill-Lync's MATLAB and Simulink basics course and its embedded systems programmes. Not sure which fits your branch and year? Talk to a Skill-Lync counsellor; it is free and there is no obligation.

Sources and further reading

Want this on your résumé?

Talk to a counsellor.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.