# Editing a Tabular Expression

The Table Tool allows users to graphically layout a tabular expression, for which conditions and outputs can be specified using the embedded Matlab subset of the Matlab language.

## Contents

- Layout
- Inputs
- Expression Name
- Conditions
- Outputs
- Ports
- Edit Mode

## Layout

The Dialog interface allows for the creation of 1-Dimensional vertical and horizontal tables, as well as 2-Dimensional tables. The tool supports multiple outputs for 1-Dimensional vertical tables.

The figure below shows an example 2-Dimensional Table with the Vertical Conditions, Horizontal Conditions, and Outputs notated.

The "new" button will create an additional condition box for a particular grid. The "delete" button will remove the last condition box in a grid. For each condition in the vertical conditions, a subgrid can be created. To create a subgrid for a condition click on the "+" button next to the intended box.

Whenever the configuration of the vertical and horizontal conditions is changed the corresponding output boxes will update as well.

## Inputs

The input box labeled "Inputs" allows for the specification of inputs to the table. There is no limit in the number of inputs supported. Inputs are specified in a comma delimited list. names of inputs must conform to the Matlab syntax conventions.

Typing

Typing information can be specified for each input declared. This allows for users to declare inputs as dependent types. The format for typing follows that of PVS, some examples:

- `x, y, z` - 3 inputs with the default type
- `x, y:bool` - 2 inputs, y with specified type, x has the default type.
- `x:real, y:real, z:bool` - 2 inputs of type real and one of type bool
- `x:real, y:{t:real|t>x}` - 2 inputs of type real, y is dependent on x, and is restricted to those value strictly greater than x

## Expression Name

the expression name will be the name identifying the block, it will also be the function name for generated Matlab code.

Typing

For single output tables, typing information for the output type of the function can be specified in this textbox. formatting for the typing is the same as that for inputs.

## Conditions

Text input for a condition box must be valid embedded Matlab code. Expressions in condition boxes will be evaluated with the assumed type of boolean. Since embedded Matlab is not typechecked this is a potential cause of errors. By running a syntax check on a table, each expression in a condition box will be checked that it is of type boolean.

For a table with multiple outputs, the horizontal condition boxes represent different outputs, more detail about this in the following section.

## Outputs

The outputs of the function are specified in the outputs grid. Outputs must be an expression that will evaluate to a definite value. Each output specified should be the same type, however since Matlab is not strongly typed, almost every possible value will be interpreted as a compatible type. The tool supports 2 output modes: single output and multiple output.

The output mode can be specified from the edit menu as seen in the following figure:

Single Output

For a single output table, the vertical grid can be used for another dimension of conditions. Each output cell shall be a single expression which will evaluate to the output under the interpreted conditions.

Multiple Output

For a table with multiple outputs, the horizontal condition grid is used to specify the outputs of the table. The same rules for typing apply as noted in the inputs and expression section of this document.

Each cell in the condition grid specifies the name (and type) of an output. See the following figure for an example. Each cell in the output grid specifies an output that corresponds to the output specified in the horizontal grid above it.

In the example below the table has 2 different outputs labeled, output1 and output2; the outputs have different types. Multiple outputs facilitates robust function specification.

## Ports

The "Ports" button will bring up the ports and data manager window (see next figure.) From here you can specify the datatypes of signals, as well as any other functionality as you would with another Simulink block.

## Edit Mode

The edit button is a toggle button which allows for the user to hide the editing buttons which include the new row, delete row, new subgrid, etc. buttons. Hiding these buttons allows for cleaner looking table with fewer distractions allowing the user to concentrate on the content in the table. see an example below.