# Data Mapper

Map integer symbols from one coding scheme to another

Utility Blocks

## Description

The Data Mapper block accepts integer inputs and produces integer outputs. You can select one of four mapping modes: ```Binary to Gray```, `Gray to Binary`, ```User Defined```, or `Straight Through`.

This block accepts a scalar, column vector, or full matrix input signal. It can accept multichannel inputs and allows for input and output data types of `double`, `single`, `int32`, `int16`, `int8`, `uint32`, `uint16`, and `uint8`. The input signal must be a non-negative value. The block truncates non-integer input signals as integer values.

Gray coding is an ordering of binary numbers such that all adjacent numbers differ by only one bit. However, the inputs and outputs of this block are integers, not binary vectors. As a result, the first two mapping modes perform code conversions as follows:

• In the `Binary to Gray` mode, the output from this block is the integer equivalent of the Gray code bit representation for the input integer.

• In the `Gray to Binary` mode, the output from this block is the integer position of the binary equivalent of the input integer in a Gray code ordering.

As an example, the table below shows both the ```Binary to Gray``` and `Gray to Binary` mappings for integers in the range 0 to 7. In the Binary to Gray Mode Output column, notice that binary representations in successive rows differ by exactly one bit. In the Gray to Binary Mode columns, notice that sorting the rows by Output value creates a Gray code ordering of Input binary representations.

Binary to Gray ModeGray to Binary Mode
InputOutputInputOutput
0 0 (000)0 (000)0
1 1 (001)1 (001)1
2 3 (011)2 (010)3
3 2 (010)3 (011)2
4 6 (110)4 (100)7
5 7 (111)5 (101)6
6 5 (101)6 (110)4
7 4 (100)7 (111)5

When you select the `User Defined` mode, you can use any arbitrary mapping by providing a vector to specify the output ordering. For example, the vector `[1,5,0,4,2,3]` defines the following mapping:

`$\begin{array}{l}0\to 1\hfill \\ 1\to 5\hfill \\ 2\to 0\hfill \\ 3\to 4\hfill \\ 4\to 2\hfill \\ 5\to 3\hfill \end{array}$`

When you select the `Straight Through` mode, the output equals the input.

## Dialog Box

Mapping mode

The type of data mapping that the block performs.

Symbol set size

Symbol set size of M restricts this block's inputs and outputs to integers in the range 0 to M-1.

Mapping vector

A vector of length M that contains the integers from 0 to M-1. The order of the elements of this vector specifies the mapping of inputs to outputs. This parameter appears only when you set Mapping mode to `User Defined`.