Approximate a one-dimensional function using dynamic table (2024)

Table of Contents
Description How This Block Differs from Other Lookup Table Blocks Inputs for Breakpoint and Table Data Lookup Table Definition How the Block Generates Output Examples Approximating the sinh Function Using the Lookup Table Dynamic Block Ports Input x — input vectorscalar | vector | 2-D array xdat — breakpoint data 1-by-n vector of strictly monotonically increasingvalues ydat — table data 1-by-n vector Output y — Approximation of y = f(x) using dynamic tabledata1-by-n vector Parameters Main Tab Lookup Method — Specify the lookup methodInterpolation-Use EndValues (default) | Interpolation-Extrapolation | Use Input Nearest | Use Input Below | Use Input Above Signal Attributes Tab Output data type — Output data typedouble (default) | 'Inherit: Inherit via back propagation' | single | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64 | boolean | fixdt(1,16,0) | fixdt(1,16,2^0,0) | <data type expression> Lock output data type setting against changes by the fixed-point tools — Option to prevent fixed-point tools from overriding Output data type off (default) | on Integer rounding mode — Rounding mode for fixed-point operations Floor (default) | Ceiling | Convergent | Nearest | Round | Simplest | Zero Saturate to max or min when overflows occur — Method of overflow action off (default) | on Block Characteristics Extended Capabilities C/C++ Code Generation Generate C and C++ code using Simulink® Coder™. PLC Code GenerationGenerate Structured Text code using Simulink® PLC Coder™. Fixed-Point Conversion Design and simulate fixed-point systems using Fixed-Point Designer™. Version History See Also Topics MATLAB Command Americas Europe Asia Pacific References

Approximate a one-dimensional function using dynamic table

expand all in page

  • Approximate a one-dimensional function using dynamic table (1)

Libraries:
Simulink / Lookup Tables

Description

How This Block Differs from Other Lookup Table Blocks

The Lookup Table Dynamic block computes an approximation of a function y= f(x) using xdat and ydatvectors. The lookup method can use interpolation, extrapolation, or the originalvalues of the input.

Using the Lookup Table Dynamic block, you can change the table data withoutstopping the simulation. For example, you can incorporate new table data if thephysical system you are simulating changes.

Inputs for Breakpoint and Table Data

The xdat vector is the breakpoint data, which must bestrictly monotonically increasing. The value of the nextelement in the vector must be greater than the value of the preceding element afterconversion to a fixed-point data type. Due to quantization, xdatcan be strictly monotonic for a floating-point data type, but not after conversionto a fixed-point data type.

The ydat vector is the table data, which is an evaluation ofthe function at the breakpoint values.

Note

The inputs to xdat and ydat cannot bescalar (one-element array) values. If you provide a scalar value to either ofthese inputs, you see an error upon simulation. Provide a 1-by-n vector to boththe xdat and ydat inputs.

Lookup Table Definition

You define the lookup table by feeding xdat and ydatas 1-by-n vectors to the block. To reduce ROM usage in the generated code for thisblock, you can use different data types for xdat andydat.

Tip

Breakpoints with even spacing can make Simulink® Coder™ generated code division-free. For more information, see fixpt_evenspace_cleanup inthe Simulink documentation and Identify questionable fixed-point operations (Embedded Coder) in the Simulink Coder documentation.

How the Block Generates Output

The block uses the input values to generate output using the method you select forLookup Method:

Lookup MethodBlock Action
Interpolation-Extrapolation

Performs linear interpolation and extrapolation of theinputs.

  • If the input matches a breakpoint, the output is thecorresponding element in the table data.

  • If the input does not match a breakpoint, the blockperforms linear interpolation between two elements ofthe table to determine the output. If the input fallsoutside the range of breakpoint values, the blockextrapolates using the first two or last twopoints.

Note

If you select this lookup method, Simulink Coder software cannot generate code for thisblock.

Interpolation-Use End Values (default)

Performs linear interpolation but does not extrapolateoutside the end points of the breakpoint data. Instead, theblock uses the end values.

Use Input Nearest

Finds the element in xdat nearest thecurrent input. The corresponding element inydat is the output.

Use Input Below

Finds the element in xdat nearest andbelow the current input. The corresponding element inydat is the output. If there is noelement in xdat below the current input, theblock finds the nearest element.

Use Input Above

Finds the element in xdat nearest andabove the current input. The corresponding element inydat is the output. If there is noelement in xdat above the current input, theblock finds the nearest element.

Note

The Use Input Nearest, Use Input Below,and Use Input Above methods perform the same action when theinput x matches a breakpoint value.

Some continuous solvers subdivide the simulation time span into major and minortime steps. A minor time step is a subdivision of the major time step. The solverproduces a result at each major time step and uses results at minor time steps toimprove the accuracy of the result at the major time step. For continuous solvers,the output of the Lookup Table Dynamic block can appear like a stair step becausethe signal is fixed in minor time step to avoid incorrect results. For moreinformation about the effect of solvers on block output, see Compare Solvers in the Simulink documentation.

Examples

expand all

This example shows how to use the Lookup Table Dynamic block to approximate the sinh function. The breakpoint data is given by the vector [-5:5] and the table data is given by the vector sinh([-5:5]). The input x is provided by the Constant block as a 1-by-3 vector containing values that are below, within, and above the breakpoint data values.

To see how each lookup method handles input values that are below, within, and above the breakpoint data values, change the value of the Lookup Method parameter on the Lookup Table Dynamic block.

Approximate a one-dimensional function using dynamic table (2)

The Lookup Table Dynamic block outputs the following values when using the specified lookup methods and inputs.

Approximate a one-dimensional function using dynamic table (3)

Ports

Input

expand all

The block accepts real-valued or complex-valued inputs.

Example: 2:12

Dependencies

The x input vector and thexdat breakpoint data must have the same sign,bias, and fractional slope. Also, the precision and range forx must be greater than or equal to theprecision and range for xdat.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | bus

The xdat vector is the breakpoint data, which mustbe strictly monotonically increasing. The value of the next element inthe vector must be greater than the value of the preceding element afterconversion to a fixed-point data type. Due to quantization,xdat can be strictly monotonic for afloating-point data type, but not after conversion to a fixed-point datatype.

Tip

Breakpoints with even spacing can make Simulink Coder generated code division-free. For more information,see fixpt_evenspace_cleanup in the Simulink documentation and Identify questionable fixed-point operations (Embedded Coder) in theSimulink Coder documentation.

Example: 1:10

Dependencies

The xdat breakpoint data and thex input vector must have the same sign, bias,and fractional slope. Also, the precision and range forx must be greater than or equal to theprecision and range for xdat.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | bus

The ydat input is a 1-by-n vector of real-valued orcomplex-valued table data, which is an evaluation of the function at thebreakpoint values.

Example: [0 3 12 27 48 75 108 147 192 243 300]

Dependencies

The ydat table data and they output vector must have the same sign,bias, and fractional slope.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | bus

Output

expand all

The block computes an approximation of a function y =f(x) using the xdat andydat input vectors. The lookup method can useinterpolation, extrapolation, or the original values of theinput.

Dependencies

The ydat table data and they output vector must have the same sign,bias, and fractional slope.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point

Parameters

expand all

Main Tab

The block computes output by applying the LookupMethod you select to the input vectors of breakpoint data(xdat) and table data (ydat).For details, see How the Block Generates Output.

Programmatic Use

Block Parameter:LookUpMeth
Type: charactervector
Values:'Interpolation-Extrapolation' | 'Interpolation-Use EndValues' | 'Use Input Nearest' | 'Use Input Below' | 'UseInput Above'
Default:'Interpolation-Use End Values'

Signal Attributes Tab

Specify the data type of the output signaly.

The Data Type Assistant helps you set dataattributes. To use the Data Type Assistant, click Approximate a one-dimensional function using dynamic table (4). For more information, see Specify Data Types Using Data Type Assistant.

Dependencies

The ydat table data and they output vector must have the same sign,bias, and fractional slope.

Programmatic Use

Block Parameter:OutDataTypeStr
Type: charactervector
Values:'Inherit: Inherit via back propagation' | 'double' |'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32'| 'uint32' | 'int64' | 'uint64' | 'boolean' |'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | <data typeexpression>
Default:'double'

Select this parameter to prevent the fixed-point tools from overriding the Output data type you specify on the block. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).

Programmatic Use

Block Parameter: LockScale
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Specify the rounding mode for fixed-point operations. For more information, see Rounding (Fixed-Point Designer).

Block parameters always round to the nearest representable value. To control the rounding of a block parameter, enter an expression using a MATLAB® rounding function into the mask field.

Programmatic Use

Block Parameter: RndMeth
Type: character vector
Values: 'Ceiling' | 'Convergent' | 'Floor' | 'Nearest' | 'Round' | 'Simplest' | 'Zero'
Default: 'Floor'

When you select this check box, overflows saturate to the maximum or minimum value that the data type can represent. Otherwise, overflows wrap.

When you select this check box, saturation applies to every internal operation on the block, not just the output or result. In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.

Programmatic Use

Block Parameter: DoSatur
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Block Characteristics

Data Types

Boolean | double | fixed point | integer | single

Direct Feedthrough

yes

Multidimensional Signals

yes

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

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

The Simulink PLC Coder™ software does not support the SimulinkLookup Table Dynamic block. For your convenience, theplclib/Simulink/Lookup Tables library contains an implementation of a dynamic tablelookup block using the Prelookup and Interpolation UsingPrelookup blocks.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced before R2006a

See Also

1-D Lookup Table | 2-D Lookup Table | n-D Lookup Table

Topics

  • Enter Data Using Inports of Lookup Table Dynamic Block
  • Nonlinearity
  • About Lookup Table Blocks
  • Anatomy of a Lookup Table
  • Guidelines for Choosing a Lookup Table

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.

Approximate a one-dimensional function using dynamic table (5)

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

Approximate a one-dimensional function using dynamic table (2024)

References

Top Articles
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated:

Views: 6126

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.