1-D data interpolation (table lookup) (2024)

1-D data interpolation (table lookup)

Since R2024a

collapse all in page

Syntax

vq = fixed.interp1(x,v,xq)

vq = fixed.interp1(v,xq)

vq = fixed.interp1(___,method)

vq = fixed.interp1(___,method,extrapval)

Description

example

vq = fixed.interp1(x,v,xq) returns interpolated values of a 1-D function at specific query points using linear interpolation. Vector x contains the coordinates of the sample points and v contains the corresponding function values at each sample point. The variable xq contains the coordinates of the query points.

If you have multiple sets of data that are sampled at the same point coordinates, then you can pass v as an array. Each column of array v contains a different set of 1-D sample values.

vq = fixed.interp1(v,xq) returns interpolated values and assumes a default set of sample point coordinates. The default points are the sequence of numbers from 1 to n, where n depends on the shape of v:

  • When v is a vector, the default points are 1:length(v).

  • When v is an array, the default points are 1:size(v,1).

Use this syntax when you are not concerned about the absolute distances between points.

vq = fixed.interp1(___,method) specifies an alternative interpolation method: "linear", "nearest", "previous", or "next". The default method is "linear".

vq = fixed.interp1(___,method,extrapval) specifies extrapval, a scalar value that is assigned to all queries that lie outside the domain of the sample points.

Examples

collapse all

Implement 1-D Fixed-Point Lookup Tables Using Interpolation

Open Live Script

This example shows how to implement a one-dimensional fixed-point lookup table using fixed.interp1.

Run the example multiple times to see the approximation over different query points.

Create Lookup Table for Function

Define a function f(x) to replace with a lookup table approximation.

clearvarsf = @(x) exp(x);

Define breakpoints x for the lookup table. Use the following values, which were computed to estimate exp(x) by the Lookup Table Optimizer and targeted 16-bit fixed-point types and on-curve table values.

x = [-11, -6.80029296875, -5.49609375, -4.708984375, -4.1484375, -3.70849609375, ... -3.3466796875, -3.04150390625, -2.7763671875, -2.54150390625, -2.33251953125, ... -2.142578125, -1.96875, -1.8095703125, -1.66259765625, -1.525390625, -1.3974609375, ... -1.27685546875, -1.16357421875, -1.05712890625, -0.95556640625, -0.85791015625, ... -0.76611328125, -0.677734375, -0.5927734375, -0.51171875, -0.43359375, -0.35791015625, ... -0.28515625, -0.21533203125, -0.1484375, -0.08349609375, -0.0205078125, 0];

Generate on-curve table values v corresponding to the breakpoints.

v = f(x);

Plot the table values and notice that the breakpoints x are not linearly spaced.

plot(x,v,'o-')

1-D data interpolation (table lookup) (1)

Query Lookup Table

Choose a random query point xq in the range of x.

xq = fixed.example.realUniformRandomArray(x(1),x(end),1);

Cast the inputs to 16-bit fixed-point.

x = fi(x);v = fi(v);xq = fi(xq);

The fixed.interp1 function computes vq, the lookup table approximation of f(xq). That is, vqf(xq).

vq = fixed.interp1(x,v,xq)
vq = 0.1307 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 14

Compare Lookup Approximation to Actual Function Value

Compare vq to the actual function evaluation f(xq).

vq_expected = f(double(xq))
vq_expected = 0.1303
err = double(vq) - vq_expected
err = 4.5947e-04

Plot f(x).

clf;plot(x,v)xlabel('x')ylabel('v')hold on

Plot vq, the lookup table approximation of f(xq), using a red stem plot.

stem(xq,vq,'Filled','red')legend('f(x)','vq = Fixed-point lookup-table approximation of f(xq)','location','best')

Input Arguments

collapse all

xSample points
vector

Sample points, specified as a row or column vector of real numbers. The values in x must be strictly monotonically increasing. The length of x must conform to one of the following requirements:

  • If v is a vector, then length(x) must equal length(v).

  • If v is an array, then length(x) must equal size(v,1).

The inputs x, v, and xq must be the same data type: fi, half, single, or double. When using fi data, you can use the shortened function name interp1.

Example: fi(1:10,0,8,0)

Example: half(1:10)

Data Types: fi | single | double

vSample values
vector | matrix | array

Sample values, specified as a vector, matrix, or array of real or complex numbers. If v is a matrix or an array, then each column contains a separate set of 1-D values.

If v contains complex numbers, then fixed.interp1 interpolates the real and imaginary parts separately.

The inputs x, v, and xq must be the same data type: fi, half, single, or double. When using fi data, you can use the shortened function name interp1.

Example: fi(rand(10,1),0,12,8)

Example: half(rand(10,1))

Data Types: fi | single | double
Complex Number Support: Yes

xqQuery points
scalar | vector | matrix | array

Query points, specified as a scalar, vector, matrix, or array of real numbers.

The inputs x, v, and xq must be the same data type: fi, half, single, or double. When using fi data, you can use the shortened function name interp1.

Example: fi(5,0,12,8)

Example: half(5)

Example: half(1:0.05:10)

Example: half((1:0.05:10)')

Example: half([0 1 2 7.5 10])

Data Types: fi | single | double

methodInterpolation method
"linear" (default) | "nearest" | "next" | "previous"

Interpolation method, specified as one of the options in this table.

Method

Description

Continuity

Comments

"linear"

Linear interpolation. The interpolated value at a query point is based on linear interpolation of the values at neighboring grid points in each respective dimension. This method is the default interpolation method.

C0

  • Requires at least 2 points

  • Requires more memory and computation time than nearest neighbor

"nearest"

Nearest neighbor interpolation. The interpolated value at a query point is the value at the nearest sample grid point.

Discontinuous

  • Requires at least 2 points

  • Modest memory requirements

  • Fastest computation time

"next"

Next neighbor interpolation. The interpolated value at a query point is the value at the next sample grid point.

Discontinuous

  • Requires at least 2 points

  • Same memory requirements and computation time as "nearest"

"previous"

Previous neighbor interpolation. The interpolated value at a query point is the value at the previous sample grid point.

Discontinuous

  • Requires at least 2 points

  • Same memory requirements and computation time as "nearest"

extrapvalFunction value outside the domain of x
scalar

Function value outside the domain of x, specified as a real or complex scalar. fixed.interp1 returns this constant value for all points outside the domain of x. If the scalar value is nonzero and outside the range of the sample values v, then this value is set to the minimum or maximum value of v, whichever is closer.

The data type of extrapval must be the same as x, v, and xq.

The default behavior with fi input data is to return 0 for query points outside the domain. The default behavior with half, single, or double input data is to return NaN for query points outside the domain.

Example: fi(5,0,12,8)

Example: half(5)

Data Types: fi | single | double

Note

The default behavior of the interp1 function is to return NaN when a query point is outside the domain. The fixed.interp1 function with fi input data is not consistent with this behavior because fi casts NaN to 0.

Output Arguments

collapse all

vq — Interpolated values
scalar | vector | matrix | array

Interpolated values, returned as a scalar, vector, matrix, or array. The size of vq depends on the shape of v and xq. The data type of vq is the same as that of the sample values v.

Shape of vShape of xqSize of VqExample
VectorVectorsize(xq)If size(v) = [1 100]
and size(xq) = [1 500],
then size(vq) = [1 500].
VectorMatrix
or N-D Array
size(xq)If size(v) = [1 100]
and size(xq) = [50 30],
then size(vq) = [50 30].
Matrix
or N-D Array
Vector[length(xq) size(v,2),...,size(v,n)]If size(v) = [100 3]
and size(xq) = [1 500],
then size(vq) = [500 3].
Matrix
or N-D Array
Matrix
or N-D Array
[size(xq,1),...,size(xq,n),... size(v,2),...,size(v,m)]If size(v) = [4 5 6]
and size(xq) = [2 3 7],
then size(vq) = [2 3 7 5 6].

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

Version History

Introduced in R2024a

See Also

fixed.interp2 | fixed.interp3 | fixed.interpn | interp1

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

1-D data interpolation (table lookup) (3)

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:

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
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

1-D data interpolation (table lookup) (2024)

FAQs

What is a 1D lookup table? ›

The one dimensional Lookup Table block performs a lookup in a user-defined table for values of the dependent variables using a single field as the index (the independent variable). The output values of the block are the corresponding values in the output field columns of the lookup table.

What is the formula for interpolation of a table? ›

The interpolation equation is as follows: y − y 1 = y 2 − y 1 x 2 − x 1 ( x − x 1 ) , where ( x 1 , y 1 ) and ( x 2 , y 2 ) are two known data points and ("x," "y") represents the data point to be estimated.

How to calculate lookup table in MATLAB? ›

Use the tablelookup function in the equations section to compute an output value by interpolating the query input value against a set of data points. This functionality is similar to that of the Simulink® and Simscape™ Lookup Table blocks.

What is the formula for 1D linear interpolation? ›

Performs 1D linear interpolation of 'xi' points using 'x' and 'y', resulting in 'yi', following the formula yi = y1 + (y2-y1)/(x2-x1)*(xi-x1).

How does a lookup table work? ›

A lookup table is an array of data that maps input values to output values, thereby approximating a mathematical function. Given a set of input values, a lookup operation retrieves the corresponding output values from the table.

What is the difference between lookup table and dimension table? ›

Dimensions define a hierarchy for the information retrieved by the lookup table, so that it can be organized and presented in a meaningful way. Lookup tables are retrieved from the Case Analyzer store. The preconfigured Case Monitor objects provide ready-made lookup tables for dimensions.

How to interpolate manually? ›

How to interpolate
  1. Organize your data. First, put the data you've collected into a chart that shows your independent and dependent variables. ...
  2. Consider creating a graph. ...
  3. Select your two points. ...
  4. Enter values into the interpolation equation. ...
  5. Solve for the missing variable.
Oct 16, 2023

What are the four interpolation methods? ›

CDT has 4 deterministic interpolation methods: inverse distance weighted, modified Shepard interpolation, Spheremap interpolation method and nearest neighbor; and 2 stochastic interpolation methods: ordinary kriging and universal kriging.

Is there an interpolation formula in Excel? ›

When using Excel, there are two main ways to use linear interpolation. The first way is plugging in the basic mathematical formula for linear interpolation. That formula is:y = y1 + (x - x1) ⨯ (y2 - y1) / (x2 - x1)In this formula, x1, x2, y1 and y2 are all known values.

What is lookup data table? ›

Lookup tables — similar to cross-reference tables — allow you to easily look up frequently used data in a recipe. Lookup tables are structured with rows and columns. You can look up entries in a lookup table by matching data in one or more columns.

Which tables are lookup tables? ›

A lookup table or LUT maps keys to values. Keys are unique and no value appears more than once. The data we save in a lookup table can be anything. For example, they can be categorical such as country names, currencies, colors, etc., or numerical.

What is interpolate 1D array? ›

Interpolate 1D Array. Calculates a decimal y-value from an array of numbers or points at a specified fractional index or x-value using linear interpolation.

What is the formula for linear interpolation in Matlab? ›

vq = interp1( x , v , xq ) returns interpolated values of a 1-D function at specific query points using linear interpolation. Vector x contains the sample points, and v contains the corresponding values, v(x). Vector xq contains the coordinates of the query points.

How to do simple linear interpolation? ›

Formula of Linear Interpolation
  1. x 1. and.
  2. y 1. are the first coordinates.
  3. x 2. and.
  4. y 2. are the second coordinates. x is the point to perform the interpolation. y is the interpolated value. Solved Examples. ...
  5. y 1. + ( x − x 1 ) ( y 2 − y 1 ) x 2 − x 1. y = 4 + ( 4 − 2 ) ( 7 − 4 ) 6 − 2.

What is the use of lookup table in Excel? ›

In computer science, a lookup table is an array of data, which is generally used to map input values to output values. In terms of this tutorial, an Excel lookup table is nothing else but a range of cells where you search for a lookup value. Main table (master table) - a table into which you pull matching values.

What is SQL lookup table? ›

A lookup table or LUT maps keys to values. Keys are unique and no value appears more than once. The data we save in a lookup table can be anything. For example, they can be categorical such as country names, currencies, colors, etc., or numerical.

What is the difference between lookup table and reference table? ›

Both types of tables are used in the mapping and translation process. The primary difference is that a lookup table has only one key field and a cross-reference table has two. A lookup table is used when you want to supplement data before it is sent to your partner.

What is the difference between lookup table and truth table? ›

The truth table maps logical combinations of input states to output states. Unlike the Digital Lookup Table, this device allows the input space to include don't care inputs. A default output state determines the output if the input state is not defined in the table.

Top Articles
Remembering Albert Ezerzer: The Unseen Hero of 'Suits' - techdeserts.com
What Happened To Albert Ezerzer and How Did He Pass Away?
Greet In Cheshire Crossword Clue
glizzy - Wiktionary, the free dictionary
How to cancel subscriptions on your iPhone through the Settings app
Saxies Lake Worth
Craigslist Pinellas County Rentals
Chronological Age Calculator - Calculate from Date of Birth
True Or False Security Is A Team Effort
Oracle Holiday Calendar 2022
UHD-4K-Monitor mit 27 Zoll und VESA DisplayHDR™ 400 - 27UQ750-W | LG DE
Gay Pnp Zoom Meetings
Estragon South End
Las mentiras y los crímenes que continúan. 9.11 X Veintitrés = Sin palabras
The Courier from Waterloo, Iowa
Math Playground Protractor
Ar Kendrithyst
Dyi Urban Dictionary
Lexington Park Craigslist
Warren P. on SoundBetter
The Front Porch Self Service
Colt Gray and his father, Colin Gray, appear in court to face charges in Georgia school shooting
Vegamovies Marathi
19 Dollar Fortnite Card Copypasta
2013 Freightliner Cascadia Fuse Box Diagram
Sharkbrew
Logisticare Transportation Provider Login
Pokimane Titty Pops Out
Insidekp.kp.org Myhr Portal
Best Auto Upholstery Shops Near Me
Haverhill, MA Obituaries | Driscoll Funeral Home and Cremation Service
Dramacool Love In Contract
Marshfieldnewsherald Obituary
Dimbleby Funeral Home
Cbs Scores Mlb
What Are The Hours Of Chase Bank Today
Classy Spa Fort Walton Beach
Paris 2024: The first Games to achieve full gender parity
Ludwig Nutsac
Sounder Mariners Schedule
Horoscope Today: Astrological prediction September 9, 2024 for all zodiac signs
Seller Feedback
Texas State Final Grades
Trap Candy Strain Leafly
911 Active Calls Caddo
Directions To Lubbock
Discord Id Grabber
19 BEST Stops on the Drive from Te Anau to Milford Sound +Road Trip Tips!
The t33n leak 5-17: Understanding the Impact and Implications - Mole Removal Service
Cargurus Button Girl
German police arrest 25 suspects in plot to overthrow state – DW – 12/07/2022
Basketball Defense: 1-3-1 half court trap
Latest Posts
Article information

Author: Dr. Pierre Goyette

Last Updated:

Views: 5245

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Dr. Pierre Goyette

Birthday: 1998-01-29

Address: Apt. 611 3357 Yong Plain, West Audra, IL 70053

Phone: +5819954278378

Job: Construction Director

Hobby: Embroidery, Creative writing, Shopping, Driving, Stand-up comedy, Coffee roasting, Scrapbooking

Introduction: My name is Dr. Pierre Goyette, I am a enchanting, powerful, jolly, rich, graceful, colorful, zany person who loves writing and wants to share my knowledge and understanding with you.