Main Content

fixpt_interp1

Implement 1-D lookup table

Syntax

y= fixpt_interp1(xdata,ydata,x,xdt,xscale,ydt,yscale,rndmeth)

Description

y= fixpt_interp1(xdata,ydata,x,xdt,xscale,ydt,yscale,rndmeth)implements a one-dimensional lookup table to find outputyfor inputx. Ifxfalls between twoxdatavalues (breakpoints),yis the result of interpolating between the correspondingydatavalues. Ifxis greater than the maximum value inxdata,yis the maximumydatavalue. Ifxis less than the minimum value inxdata,yis the minimumydatavalue.

If the input data typexdtor the output data typeydtis floating point,fixpt_interp1performs the interpolation using floating-point calculations. Otherwise,fixpt_interp1uses integer-only calculations. These calculations handle the input scalingxscaleand the output scalingyscaleand obey the rounding methodrndmeth.

Input Arguments

xdata

Vector of breakpoints for the lookup table, such aslinspace(0,8,33).

ydata

Vector of table data that correspond to the breakpoints for the lookup table, such assin(xdata).

x

Vector of input values for the lookup table to process, such aslinspace(-1,9,201).

xdt

Data type of inputx, such assfix(8).

xscale

Scaling for inputx, such as2^-3.

ydt

Data type of outputy, such assfix(16).

yscale

Scaling for outputy, such as2^-14.

rndmeth

Rounding mode supported by fixed-point Simulink®blocks:

'Ceiling'

Round to the nearest representable number in the direction of positive infinity.

'Floor'(default)

Round to the nearest representable number in the direction of negative infinity.

'Nearest'

Round to the nearest representable number.

'Toward Zero'

Round to the nearest representable number in the direction of zero.

Examples

Interpolate outputs forxusing a 1-D lookup table that approximates the sine function:

xdata = linspace(0,8,33).'; ydata = sin(xdata); % Define input x as a vector of 201 evenly % spaced points between -1 and 9 (includes % values both lower and higher than the range % of breakpoints in xdata) x = linspace(-1,9,201).'; % Interpolate output values for x y = fixpt_interp1(xdata,ydata,x,sfix(8),2^-3,sfix(16),... 2^-14,'Floor')
Introduced before R2006a