Main Content

Set Data Types in Requirements Table Blocks

When you create data in a Requirements Table block, you can use the Type property to set the data type. Data can inherit their data types, or be set to built-in, fixed-point, or enumerated data types. Data can also be nonvirtual buses. By default, Requirements Table block data inherit their data type.

For more information about creating data, see Define Data in Requirements Table Blocks.

Specify Data Types

You can specify the data types by using the Symbols pane and Property Inspector, or the Model Explorer.

To specify the data type using the Symbols pane and Property Inspector:

  1. Open the Requirements Table block.

  2. Open the Symbols pane. In the Modeling tab, in the Design Data section, click Symbols Pane.

  3. Right-click the data you want to modify and click Inspect to open the data properties in the Property Inspector.

  4. In the Properties tab, select the data type in the Type property.

To specify the data type using the Model Explorer:

  1. Open the Model Explorer. In the Modeling tab, in the Design Data section, click Model Explorer.

  2. In the Model Hierarchy pane, expand the model tree view and select the Requirements Table block.

  3. Click the data you want to modify.

  4. Select the data type in the Type property.

In the Model Explorer, you can also filter the data type options. In the General tab, click the Show data type assistant button to display the Data Type Assistant. Then choose an option from the Mode drop-down menu. The available data types depend on the mode you select:

ModeWhat to Specify
Inherit (default)

The data type is inherited based on the Scope property:

  • If Scope is Input, the data type is inherited from the input signal on the designated port.

  • If Scope is Output, the data type is inherited from the output signal on the designated port.

  • If Scope is set to the other options, the data type is inherited from the associated parameter, which can be defined in the Simulink® masked subsystem or the MATLAB® workspace.

Built inSelect a supported built-in data type.
Fixed point

Specify the fixed-point data properties.

EnumeratedEnter the name of a Simulink.IntEnumType object that you define in the base workspace.
Bus Object

Enter the name of a Simulink.Bus object to define the properties of a MATLAB structure. You must define the bus object in the base workspace.

Note

You can click the Edit button to create or modify Simulink.Bus objects using the Simulink Type Editor.

ExpressionEnter an expression that evaluates to a data type.

Inheriting Data Types

Requirements Table block data can inherit their data types, including fixed-point types, from their connected signals. To set data to inherit its data type:

  1. Select the data in the Model Explorer. Alternatively, select the data in the Symbols pane and open the Property Inspector.

  2. In the Model Explorer or Property Inspector, set Type to Inherit: Same as Simulink.

Data with the Scope property set to Local, Parameter, Input, or Output can also inherit complexity from the information sent to it. To inherit complexity, set Complexity to Inherited.

After you build the model, the CompiledType column of the Model Explorer shows the actual data type inherited from Simulink. If the expected type matches the inferred type, the Requirements Table block inherits the data type.

Specify Built-In Data Types

In the Model Explorer, when you expand the Data Type Assistant and set Mode to Built in, you can set Type to these built-in data types. The built-in data types are:

Data TypeDescription

double

64-bit double-precision floating point

single

32-bit single-precision floating point

half

A half-precision data type occupies 16 bits of memory, but its floating-point representation enables it to handle wider dynamic ranges than integer or fixed-point data types of the same size. See The Half-Precision Data Type in Simulink (Fixed-Point Designer).

int64

64-bit signed integer

int32

32-bit signed integer

int16

16-bit signed integer

int8

8-bit signed integer

uint64

64-bit unsigned integer

uint32

32-bit unsigned integer

uint16

16-bit unsigned integer

uint8

8-bit unsigned integer

boolean

Boolean

string

String scalar

Fixed-Point Designer Data Properties

To represent data as fixed-point numbers in Requirements Table blocks, you must install Fixed-Point Designer™.

You can set the following fixed-point properties:

Signedness

Select whether you want the fixed-point data to be Signed or Unsigned. Signed data can represent positive and negative quantities. Unsigned data represents positive values only. The default is Signed.

Word length

Specify the size, in bits, of the word that will hold the quantized integer. Large word sizes represent large quantities with greater precision than small word sizes. Word length can be any integer between 0 and 128 bits. The default is 16.

Scaling

Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization issues. You can select these scaling modes:

Scaling ModeDescription
Binary point (default)

The Data Type Assistant displays the Fraction Length parameter, which specifies the binary point location.

Binary points can be positive or negative integers. A positive integer moves the binary point left of the rightmost bit by that amount. For example, an entry of 2 sets the binary point in front of the second bit from the right. A negative integer moves the binary point further right of the rightmost bit by that amount, as in this example:

Shows a graphical representation of binary points.

The default is 0.

Slope and bias

The Data Type Assistant displays the Slope and Bias parameters:

  • Slope can be any positive real number. The default is 1.0.

  • Bias can be any real number. The default value is 0.0.

You can enter slope and bias as expressions that contain parameters defined in the MATLAB workspace.

Note

Use binary-point scaling whenever possible to simplify the implementation of fixed-point numbers in generated code. Operations with fixed-point numbers that use binary-point scaling are performed with simple bit shifts and eliminate the expensive code implementations required for separate slope and bias values.

Data type override

Specify whether the data type override setting is Inherit or Off. See Fixed-Point Instrumentation and Data Type Override (Fixed-Point Designer).

Calculate Best-Precision Scaling

Have Simulink automatically calculate best-precision values for both Binary point and Slope and bias scaling, based on the Minimum and Maximum properties you specify.

To automatically calculate best precision scaling values:

  1. Specify the Minimum or Maximum properties.

  2. Click Calculate Best-Precision Scaling.

Simulink calculates the scaling values, then displays them in either the Fraction length, or the Slope and Bias fields.

Note

The Minimum and Maximum properties do not apply to data with the Scope property set to Constant or Parameter. The software cannot calculate best-precision scaling for these kinds of data.

Fixed-point details

Displays information about the fixed-point data that is defined in the Data Type Assistant:

  • Minimum and Maximum show the same values that you specify in the Minimum and Maximum properties.

  • Representable minimum, Representable maximum, and Precision show the minimum value, maximum value, and precision that the fixed-point data can represent.

This image shows the fixed-point details for data named data.

If the value of a field cannot be determined without first compiling the model, the Fixed-point details subpane shows the value as Unknown. The values displayed by the Fixed-point details subpane do not automatically update if you change the values that define the fixed-point data. To update the values shown in the Fixed-point details subpane, click Refresh Details.

Clicking Refresh Details does not modify the data. It changes only the display. To apply the displayed values, click Apply or OK.

The Fixed-point details subpane indicates issues resulting from the fixed-point data specification. For example, this subpane shows two issues.

This image shows the fixed-point details for data named data with two issues.

The row labeled Maximum indicates that the value specified by the Maximum property is not representable by the fixed-point data. To fix the issue, make one of these modifications so the fixed-point data can represent the maximum value:

  • Decrease the value in the Maximum property.

  • Increase Word length.

  • Decrease Fraction length.

The row labeled Minimum shows the message Cannot evaluate because evaluating the expression MySymbol, specified by the Minimum property, does not return a numeric value. When an expression does not evaluate, the Fixed-point details subpane shows the unevaluated expression (truncating to 10 characters) in place of the unavailable value. To fix this issue, define MySymbol in the base workspace to provide a numeric value.

If you click Refresh Details, the issue indicators and descriptions are removed and the value of MySymbol appears in place of the unevaluated text.

Enumerated Data Types

In the Model Explorer or the Property Inspector, you can specify enumerated data explicitly or make the data inherit it. To explicitly set data to an enumerated type, set Type to Enum: <class name> and replace <class name> with the name of an enumerated data type that you define in a MATLAB file on the MATLAB path. To inherit the enumerated type from a connected Simulink signal, set Type to Inherit: Same as Simulink. You can only inherit enumerated type data when the Scope property is Input. For more information, see Use Enumerated Data in Simulink Models (Simulink).

Bus Objects

In the Model Explorer or Property Inspector, when you set Type to Bus: <object name>, you can set the data type to a bus. Replace <object name> with the name of the Simulink.Bus. Requirements Table blocks support only nonvirtual buses. See Composite Interface Guidelines (Simulink). For Requirements Table block bus inputs, incoming virtual bus signals are converted to nonvirtual buses.

You can connect bus inputs and outputs from Requirements Table blocks to other bus signals, including:

  • Blocks that output bus signals, such as Bus Creator blocks.

  • Blocks that accept bus signals as an input, such as Bus Selector and Gain blocks.

  • S-Function blocks.

  • Other Requirements Table blocks.

Expression Data Types

You can specify the types of Requirements Table block data as expressions by using the Model Explorer or the Property Inspector.

To use the Model Explorer, set the Mode property to Expression. In the Type property, replace <data type expression> with an expression that evaluates to a data type.

To use the Property Inspector, double-click the Type property, clear the contents, and enter an expression.

You can use the following expressions:

  • Alias type from the MATLAB workspace, as described in Simulink.AliasType (Simulink).

  • fixdt (Simulink) function to create a Simulink.NumericType object describing a fixed-point or floating-point data type.

  • type (Stateflow) operator, to base the type on previously defined data.

For example, suppose you want to designate the variable myDataType as an alias for a single data type to use as an expression in the Type property of an input data. Create an instance of the Simulink.AliasType class and set its BaseType property by entering these commands:

myDataType = Simulink.AliasType;
myDataType.BaseType = "single";

In the Property Inspector, enter the data type alias name, myDataType, as the value in the Type property.

This image shows the property inspector after entering the expression for the data type.

See Also

Related Topics