Contenido principal

Simulink.LookupTable

Store and share lookup table and breakpoint data, and configure data for ASAP2 and AUTOSAR code generation

Description

A Simulink.LookupTable object stores lookup table and breakpoint data. You can use that data in a lookup table block such as the n-D Lookup Table block. With the object, you can specify data types and code generation settings for the table and the breakpoint sets.

When you store all of the table and breakpoint set data in a single Simulink.LookupTable object, all of the data is created in a single structure in the generated code. To configure standard axis (STD_AXIS) code generation for calibration, use this technique.

To share a breakpoint set between multiple lookup tables, such as for common axis (COM_AXIS) code generation, use a Simulink.Breakpoint object in one or more Prelookup blocks. Use Simulink.LookupTable objects in Interpolation Using Prelookup blocks. Then, configure the lookup table objects to refer to the breakpoint object. For more information, see Package Shared Breakpoint and Table Data for Lookup Tables.

Creation

Description

LUTObj = Simulink.LookupTable returns a Simulink.LookupTable object LUTObj with default property values.

To create a Simulink.LookupTable object by using the Model Explorer, click the Add Simulink LookupTable button and select Simulink LookupTable. The default name for the object is Object.

Properties

expand all

Breakpoint set information, specified as a vector of Simulink.lookuptable.Breakpoint objects, a cell array of character vectors, or a vector of Simulink.lookuptable.Evenspacing objects.

If you use a vector of Simulink.lookuptable.Breakpoint objects, each object represents a breakpoint set. To use a vector of Simulink.lookuptable.Breakpoint objects, set the property BreakpointsSpecification to "Explicit values".

If you use a cell array of character vectors, each character vector represents the name of a Simulink.Breakpoint object. To use a cell array of character vectors, set the property BreakpointsSpecification to "Reference".

If you use a vector of Simulink.lookuptable.Evenspacing objects, each object represents a breakpoint set. To use a vector of Simulink.lookuptable.Evenspacing objects, set the property BreakpointsSpecification to "Even Spacing".

Source of the breakpoint set information, specified as "Explicit values' (default), "Even spacing", or "Reference".

Data Types: char | string

Code generation settings for the structure variable (if you set BreakpointsSpecification to "Explicit values" or "Even spacing") or array variable ("Reference") that stores the lookup table and breakpoint sets, specified as a Simulink.CoderInfo object. You can specify a storage class or custom storage class by using this embedded object. See Simulink.CoderInfo.

Settings for the structure type that the structure variable uses in the generated code, specified as a Simulink.lookuptable.StructTypeInfo object.

If you set BreakpointsSpecification to "Reference", the Simulink.LookupTable object does not appear in the generated code as a structure. The code generator ignores this property.

Option to simulate model or generate code with tunability of the effective size of the table, specified as logical 1(true) or 0(false).

Data Types: logical

Information for the table data, specified as a Simulink.lookuptable.Table object.

Examples

collapse all

Create a Simulink.LookupTable object named myLookupTable. Then specify the table data, breakpoint set data, and the name for the structure that represents the lookup table in the generated code.

myLookupTable = Simulink.LookupTable;
myLookupTable.Table.Value = [1.1 2.2 3.3 4.4 5.5];
myLookupTable.Breakpoints(1).Value = [-2 -1 0 1 2];
myLookupTable.StructTypeInfo.Name = 'myLookupTableStruct';

You can use myLookupTable in a 1-D Lookup Table block dialog box. In the block, set Data specification to Lookup table object and Name to myLookupTable.

To view the data, use the property dialog box as described in Edit Lookup Table Data with Lookup Table Spreadsheet.

Create a Simulink.LookupTable object named myLookupTable and specify the table data.

myLookupTable = Simulink.LookupTable;
myLookupTable.Table.Value = [1.1 2.2 3.3 4.4 5.5; ...
                          6.6 7.7 8.8 9.9 10.1];

Specify the breakpoint set data. In the Breakpoints property, use the vector indices 1 and 2 to set the values in the first and second breakpoint sets, respectively.

myLookupTable.Breakpoints(1).Value = [-1 1];

myLookupTable.Breakpoints(2).Value = [-2 -1 0 1 2];

By assigning these values, you create Simulink.lookuptable.Breakpoint objects as elements of the vector stored in the Breakpoints property. Except for the Value property, these new objects have default property values.

Specify a name for the structure that represents the lookup table in the generated code.

myLookupTable.StructTypeInfo.Name = "myLookupTableStruct";

You can use myLookupTable in a 2-D Lookup Table block dialog box.

To view the data, use the property dialog box as described in Edit Lookup Table Data with Lookup Table Spreadsheet.

Create a lookup table that has a breakpoint set that starts at 1, and has a spacing of 2 between each point.

Create a Simulink.LookupTable object named myLookupTable.

myLookupTable = Simulink.LookupTable;

Set up the breakpoint property to even spacing.

myLookupTable.BreakpointsSpecification = "Even spacing";

Get the properties of the breakpoint set information.

myLookupTable.Breakpoints(1)

ans = 

  Evenspacing with properties:

         FirstPoint: 0
            Spacing: 1
           DataType: 'auto'
                Min: []
                Max: []
               Unit: ''
     FirstPointName: 'BPFirstPoint1'
        SpacingName: 'BPSpacing1'
    TunableSizeName: 'N1'
        Description: ''

Specify the first point of the breakpoint set.

myLookupTable.Breakpoints(1).FirstPoint = 1;

Specify the spacing between each point in the breakpoint set.

myLookupTable.Breakpoints(1).Spacing = 2;

Get the breakpoint set information.

myLookupTable.Breakpoints(1)
ans = 

  Evenspacing with properties:

         FirstPoint: 1
            Spacing: 2
           DataType: 'auto'
                Min: []
                Max: []
               Unit: ''
     FirstPointName: 'BPFirstPoint1'
        SpacingName: 'BPSpacing1'
    TunableSizeName: 'N1'
        Description: ''

Limitations

When blocks in a subsystem use Simulink.LookupTable or Simulink.Breakpoint objects, setting data type override only on the subsystem is not supported. Instead, set data type override on the entire model.

Version History

Introduced in R2016b

expand all