Main Content

# Map

Approximate two-dimensional function

Libraries:
AUTOSAR Blockset / Classic Platform / Library Routines / Interpolation

## Description

The Map block performs two-dimensional, interpolated table lookup, including index searches. The table is a sampled representation of a function in two variables. Breakpoint sets relate the input values to positions in the table. You can also use the Prelookup and Prelookup Using Map blocks together to perform the same operations as this block.

When you set the Math and Data Types > Use algorithms optimized for row-major array layout configuration parameter, the block behavior changes from column-major to row-major. For these blocks, the column-major and row-major algorithms might differ in the order of the output calculations, possibly resulting in slightly different numeric values. This capability requires Simulink Coder™ or Embedded Coder™ software. For more information on row-major support, see Code Generation of Matrices and Arrays (Simulink Coder).

If you select the AUTOSAR 4.0 code replacement library (CRL) for your AUTOSAR model, code generated from this block is replaced with the AUTOSAR library routine that you configure in the block parameters dialog box.

## Ports

### Input

expand all

Real-valued inputs to the first port, mapped to an output value by looking up or interpolating the table of values that you define.

Example: 0:10

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

Real-valued inputs to the second port, mapped to an output value by looking up or interpolating the table of values that you define.

Example: 0:10

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

### Output

expand all

Output generated by looking up or estimating table values based on input values. If the inputs match the index values of breakpoint sets, the map block provides a table value as output. If the block inputs do not match index values in breakpoint sets, but are within range, the block performs the configured interpolation method and provides an estimated value from the table as output.

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

## Parameters

expand all

If you select the AUTOSAR 4.0 code replacement library (CRL) for your model, code generated from this block is replaced from the selected AUTOSAR routine library. This parameter enables you to choose either fixed-point (IFX) or floating-point (IFL) code replacement and validation checks.

This parameter reflects the name of the AUTOSAR code replacement library (CRL) routine used to replace the code generated by this block. The naming convention includes the targeted routine library, interpolation method, and block type. This parameter is reference-only and must not be edited.

### Table Specification

From the list, select:

• Table and breakpoints — Specify the table data and breakpoints. Selecting this option enables these parameters:

• Table data

• Breakpoints specification

• Breakpoints 1

• Breakpoints 2

• Lookup table object — Use an existing lookup table (Simulink.LookupTable) object. Selecting this option enables the Name field and the button.

#### Programmatic Use

 Block Parameter: DataSpecification Type: character vector Values: 'Table and breakpoints' | 'Lookup table object' Default: 'Table and breakpoints'

Enter the name of the lookup table (Simulink.LookupTable) object.

#### Dependencies

To enable this parameter, set Data specification to Lookup table object.

#### Programmatic Use

 Block Parameter: LookupTableObject Type: character vector Values: name of a Simulink.LookupTable object Default: ''

Enter the table of output values.

During simulation, the matrix size must be two dimensional. However, during block diagram editing, you can enter an empty matrix (specified as []) or an undefined workspace variable. This technique lets you postpone specifying a correctly dimensioned matrix for the table data and continue editing the block diagram.

#### Dependencies

To enable this parameter, set Data specification to Table and breakpoints.

#### Programmatic Use

 Block Parameter: Table Type: character vector Values: matrix of table values Default: '[4 5 6;16 19 20;10 18 23]'

Specify whether to enter data as explicit breakpoints or as parameters that generate evenly spaced breakpoints.

• To explicitly specify breakpoint data, set this parameter to Explicit values and enter breakpoint data in the text box next to the Breakpoints parameters.

• To specify parameters that generate evenly spaced breakpoints, set this parameter to Even spacing and enter values for the First point and Spacing parameters for each dimension of breakpoint data. The block calculates the number of points to generate from the table data.

#### Dependencies

To enable this parameter, set Data specification to Table and breakpoints.

#### Programmatic Use

 Block Parameter: BreakpointsSpecification Type: character vector Values: 'Explicit values' | 'Even spacing' Default: 'Explicit values'

Specify the breakpoint data explicitly or as evenly-spaced breakpoints, based on the value of the Breakpoints specification parameter.

• If you set Breakpoints specification to Explicit values, enter the breakpoint set that corresponds to each dimension of table data in each Breakpoints row. For each dimension, specify breakpoints as a 1-by-n or n-by-1 vector whose values are strictly monotonically increasing.

• If you set Breakpoints specification to Even spacing, enter the parameters First point and Spacing in each Breakpoints row to generate evenly-spaced breakpoints in the respective dimension. Your table data determines the number of evenly spaced points.

#### Dependencies

To enable this parameter, set Data specification to Table and breakpoints.

#### Programmatic Use

 Block Parameter: BreakpointsForDimension1 | BreakpointsForDimension2 Type: character vector Values: 1-by-n or n-by-1 vector of monotonically increasing values Default: '[10, 22, 31]'

Specify the first point in your evenly spaced breakpoint data as a real-valued, finite, or scalar. This parameter is available when you set the Breakpoints specification to Even spacing.

#### Dependencies

To enable this parameter, set Data specification to Table and breakpoints and Breakpoints specification to Even spacing.

#### Programmatic Use

 Block Parameter: BreakpointsForDimension1FirstPoint | BreakpointsForDimensionSecondPoint Type: character vector Values: real-valued, finite, scalar Default: '1'

Specify the spacing between points in your evenly-spaced breakpoint data.

#### Dependencies

To enable this parameter, set Data specification to Table and breakpoints and Breakpoints specification to Even spacing.

#### Programmatic Use

 Block Parameter: BreakpointsForDimension1Spacing | BreakpointsForDimension2Spacing Type: character vector Values: positive, real-valued, finite, scalar Default: '1'

Click this button to open the Lookup Table Editor. You can then edit the object and save the new values for the object. For more information, see Edit Lookup Tables in the Simulink ® documentation.

### Algorithm

Select Evenly spaced points, Linear search, or Binary search. Each search method has speed advantages in different circumstances:

• For evenly spaced breakpoint sets (for example, 10, 20, 30, and so on), you achieve optimal speed by selecting Evenly spaced points to calculate table indices. This algorithm uses only the first two breakpoints of a set to determine the offset and spacing of the remaining points.

Note

When using the Simulink.LookupTable object to specify table data and the Breakpoints Specification parameter of the referenced Simulink.LookupTable object is set to Even spacing, set the Index search method to Evenly spaced points.

• For unevenly spaced breakpoint sets, follow these guidelines:

• If input signals do not vary significantly between time steps, selecting Linear search with Begin index search using previous index result produces the best performance.

• If input signals jump more than one or two table intervals per time step, selecting Binary search produces the best performance.

A suboptimal choice of an index search method can lead to slow performance of models that rely heavily on lookup tables.

The generated code stores only the first breakpoint, the spacing, and the number of breakpoints when:

• The breakpoint data is not tunable.

• The index search method is Evenly spaced points.

#### Programmatic Use

 Block Parameter: IndexSearchMethod Type: character vector Values: 'Binary search' | 'Evenly spaced points' | 'Linear search' Default: 'Linear search'

Select this check box when you want the block to start its search using the index found at the previous time step. For inputs that change slowly with respect to the interval size, enabling this option can improve performance. Otherwise, the linear search and binary search methods can take longer, especially for large breakpoint sets.

#### Dependencies

To enable this parameter, set Index search method to Linear search or Binary search.

#### Programmatic Use

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

When an input falls between breakpoint values, the block interpolates the output value by using neighboring breakpoints. For more information, see Interpolation Methods.

#### Programmatic Use

 Block Parameter: InterpMethod Type: character vector Values: 'Linear point-slope' | 'Flat' Default: 'Linear point-slope'

Specify the rounding mode for fixed-point or floating-point lookup table calculations that occur during simulation or execution of code generated from the model.

This option does not affect rounding of block parameter values. Simulink rounds such values to the nearest representable integer value. To control the rounding of a block parameter, enter an expression using a MATLAB™ rounding function into the edit field on the block dialog box.

#### Programmatic Use

 Block Parameter: RndMeth Type: character vector Values: 'Round' | 'Zero' Default: 'Round'

### Data Types

Specify the table data type. The block validates that the selected types are compatible with the specification of the targeted routine. You can set the table data type to:

• A rule that inherits a data type, for example, Inherit: Same as output

• The name of a built-in data type, for example, single

• The name of a data type object, for example, a Simulink.NumericType object

• An expression that evaluates to a data type, for example, fixdt(1,16,0)

Click the button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant.

Tip

Specify a table data type different from the output data type in these cases:

• Lower memory requirement for storing table data that uses a smaller type than the output signal.

• Sharing of prescaled table data between two Map blocks that have different output data types.

• Sharing of custom storage table data in the generated code for blocks that have different output data types.

#### Programmatic Use

 Block Parameter: TableDataTypeStr Type: character vector Values: 'Inherit: Inherit from 'Table data'' | 'Inherit: Same as output' | 'double' | 'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'fixdt(1,16)' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)'|'' Default: 'Inherit: Same as output'

Specify the data type for a set of breakpoint data. You can set the breakpoint data type to:

• A rule that inherits a data type, for example, Inherit: Same as corresponding input

• The name of a built-in data type, for example, single

• The name of a data type class, for example, an enumerated data type class

• The name of a data type object, for example, a Simulink.NumericType object

• An expression that evaluates to a data type, for example, fixdt(1,16,0)

A limitation for using enumerated data with this block is that it does not support out-of-range input for enumerated date. When specifying enumerated data, include the entire enumeration set in the breakpoint data set.

Click the button to display the Data Type Assistant, which helps you set the data type attributes. For more information, see Specify Data Types Using Data Type Assistant.

#### Programmatic Use

 Block Parameter: BreakpointsForDimension1DataTypeStr | BreakpointsForDimension2DataTypeStr Type: character vector Values: 'Inherit: Same as corresponding input' | 'Inherit: Inherit from 'Breakpoint data'' | 'double' | 'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'fixdt(1,16)' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)'|'' Default: 'Inherit: Same as corresponding input'

## Version History

Introduced in R2019a