Main Content

Display

Show value of input

  • Display block

Libraries:
Simulink / Sinks
HDL Coder / Sinks

Description

The Display block shows the value of the input data. You can specify the frequency of the display. For numeric input data, you can also specify the format of display.

If the block input is an array, you can resize the block vertically or horizontally to show more than just the first element. If the block input is a vector, the block sequentially adds display fields from left to right and top to bottom. The block displays as many values as possible. A black triangle indicates that the block is not displaying all input array elements.

The Display block shows the first 200 elements of a vector signal and the first 20 rows and 10 columns of a matrix signal.

Note

If you specify a numeric display format that is not large enough to display all the digits of a value, the displayed values may lose precision. The result depends on your computer hardware and operating system.

Display Abbreviations

The following abbreviations appear on the Display block to help you identify the format of the value.

When You See...The Value That Appears Is...

(SI)

The stored integer value

Note

(SI) does not appear when the signal is of an integer data type.

hex

In hexadecimal format

bin

In binary format

oct

In octal format

Displaying Strings

When working with strings, the Display block displays:

  • Strings with double quotes.

  • Special characters such as newline are shown as escaped sequences, for example '\n'.

  • Non-displayable characters as escaped octal number, for example '\201'.

If the incoming signal is of type string, the Numeric display format parameter selection does not affect the display of the string.

Examples

expand all

This example shows how the Sum block reorders inputs. If you use a - sign as the first operation, the block reorders the inputs, if possible, to use a + operation. For example, in the expression output = -a-b+c, the Sum block reorders the input so that output = c-a-b. To initialize the accumulator, the Sum block uses the first + input port.

The block avoids performing a unary minus operation on the first operand a because doing so can change the value of a for fixed-point data types. In that case, the output value differs from the result of accumulating the values for a, b, and c.

Both the constant inputs use int8 data types The Sum block also uses int8 for the accumulator and output data types and has Saturate on integer overflow turned on. The Sum block reorders the inputs to give the ideal result of 127.

  1. Reorders inputs from (-Input1 + Input2) to (Input2 - Input1).

  2. Initializes the accumulator by using the first + input port. Accumulator = int8(-1) = -1

  3. Continues to accumulate values. Accumulator = Accumulator - int8(-128) = 127

  4. Calculates the block output. Output = int8(127) = 127

If the Sum block does not reorder the inputs, then you get the nonideal result of 126.

  1. Initializes the accumulator by using the first input port. Accumulator = int8(-(-128)) = 127

  2. Because saturation is on, the initial value of the accumulator saturates at 127 and does not wrap.

  3. Continues to accumulate values. Accumulator = Accumulator + int8(-1) = 126

  4. Calculates the block output. Output = int8(126) = 126

To explicitly specify a unary minus operation for output = -a-b+c, you can use the Unary Minus block in the Math Operations library.

This example shows a model that provides a scalar input to a Coulomb & Viscous Friction block. The Coulomb & Viscous Friction uses scalar expansion to produce a vector output.

Double click the Coulomb & Viscous Friction block to see the parameters. The Coefficient of viscous friction (Gain) parameter has a scalar value of 2, and the Coulomb friction value (Offset) parameter has a vector value of [1 3 2 0]. Because the dimensions of the input and the dimensions of the offset are different, the block uses element-wise scalar expansion to compute the output.

Each output is calculated using this formula.

$y = sign(x) .* (Gain .* abs(x) + Offset(idx))$

For example, this equation shows the calculation for the first offset, 1.

$y = - * ((2 * 5) + 1)$

$y = -11$

No scalar expansion is necessary if the input and offset have the same dimensions.

Extended Examples

Ports

Input

expand all

Input data to display.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | string | Boolean | fixed point | enumerated

Parameters

expand all

Specify the format of the numeric data that appears.

If You Select...The Block Displays...
short A 5-digit scaled value with fixed decimal point
long A 15-digit scaled value with fixed decimal point
short_e A 5-digit value with a floating decimal point
long_e A 16-digit value with a floating decimal point
bank A value in fixed dollars and cents format (but with no $ or commas)
hex (Stored Integer) The stored integer value of a fixed-point input in hexadecimal format
binary (Stored Integer) The stored integer value of a fixed-point input in binary format
decimal (Stored Integer) The stored integer value of a fixed-point input in decimal format
octal (Stored Integer) The stored integer value of a fixed-point input in octal format

If the numeric input to a Display block has a single, double, or half data type, and the display format is a stored-integer, the output displays using the long format.

If the numeric input to a Display block has an enumerated data type (see Simulink Enumerations and Define Simulink Enumerations):

  • The block displays enumerated values, not the values of underlying integers.

  • Setting Numeric display format to any of the Stored Integer settings causes an error.

If the incoming signal is of type string, the selection of the Numeric display format parameter does not affect the display of the string.

Programmatic Use

Block Parameter: Format
Type: character vector
Values: 'short' | 'long' | 'short_e' | 'long_e' | 'bank' | 'hex (Stored Integer)' | 'binary (Stored Integer)' | 'decimal (Stored Integer)' | 'octal (Stored Integer)'
Default: 'short'

Specify how often to display data.

The amount of data that appears and the time steps at which the data appears depend on the Decimation block parameter and the SampleTime property.

  • The Decimation parameter enables you to display data at every nth sample, where n is the decimation factor. The default decimation, 1, displays data at every time step.

    Note

    The Display block updates its display at the initial time, even when the Decimation value is greater than one.

  • The SampleTime property, which you can set with set_param, enables you to specify a sampling interval at which to display points. This property is useful when you are using a variable-step solver where the interval between time steps is not the same. The default sample time, -1, causes the block to ignore the sampling interval when determining the points to display.

    Note

    If the block inherits a sample time of Inf, the Decimation parameter is ignored.

Programmatic Use

Block Parameter: Decimation
Type: character vector
Values: '1' | integer
Default: '1'

To use the block as a floating display, select Floating display. The block input port disappears and the block displays the value of the signal on a selected line.

If you select Floating display:

  • Turn off signal storage reuse for your model. See Signal storage reuse (Simulink Coder) for more information.

  • Do not connect a multidimensional signal to a floating display.

Programmatic Use

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

Block Characteristics

Data Types

Boolean | double | enumerated | fixed point | half | integer | single | string

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

yes

Zero-Crossing Detection

no

Extended Capabilities

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced before R2006a