Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 36 ยท Signals and Subsystems

Simulink Signals, Dimensions and Data Types: double, int8, boolean, fixed-point

Learn signal dimensions (scalar, vector, matrix), data types (double, single, integers, boolean, fixed-point, enumerations), overflow, type conversion and how to display them in a model.

Every line in a Simulink model carries a signal, and each signal has three properties besides its value: a dimension (how many numbers), a data type (how they are stored) and a sample time (when they are updated). Most models just work with the defaults, but when you move to embedded targets, unexpected overflow, mismatched dimensions and type errors become the most common source of bugs. This lesson gives you the vocabulary to read and control them.

Simulink does not run on this site. The product behavior is described from the documentation; Python stand-ins reproduce integer overflow and fixed-point rounding so you can try the arithmetic.

Seeing signal properties

On the Debug tab choose Information Overlays and turn on Signal Dimensions, Port Data Types and Sample Time Colors. Press Ctrl+D to update the diagram, and each line is labeled. (The labels appear only after the model is compiled; menus differ slightly between releases.) A signal with the label [3x1] is a column of three elements.

Dimensions

Kind Example Notes
Scalar 5 A single element; dimension 1
Vector (1-D) [1 2 3] Dimension 3; treated as a vector, not a row or column
Row / column matrix 1x3 / 3x1 2-D arrays
Matrix 2x3 Two dimensions
N-D array 2x3x4 More dimensions, supported by many blocks

Blocks apply scalar expansion: a scalar input combined with a vector input is expanded across all elements, so Gain = 2 times a 3-element vector doubles every element. Matrices need care: the Gain block's Multiplication setting chooses between element-wise (K.*u) and matrix (K*u) multiplication.

You create vectors with Mux (multiple scalars to one vector), Vector Concatenate and Matrix Concatenate, and split them with Demux, Selector and Reshape. See Routing, Switches and Buses.

Data types

Type Meaning Range or note
double 64-bit floating point Default for most signals
single 32-bit floating point About 7 digits; half the memory
int8, int16, int32 (int64) Signed integers e.g. int8: -128 to 127
uint8, uint16, uint32 (uint64) Unsigned integers e.g. uint8: 0 to 255
boolean True/false Logic and relational blocks produce it
fixdt(s,w,f) Fixed-point Signedness s, word length w, fraction length f
Enum: Name Enumerated type Named states
string Text Supported by some blocks

Many blocks have an Output data type parameter in their Signal Attributes tab (choose Inherit: Inherit via internal rule, Inherit: Same as input, or a specific type such as int16). By default the data type propagates from the sources through the diagram, and conflicts raise an error. A source's Output data type can be forced; type propagation then follows.

Three signal properties

Dimension Scalar, vector, matrix
Data type double, int8, boolean
Sample time Continuous or discrete

Check all three when a model misbehaves.

1 / 2

Converting types

Use the Data Type Conversion block (Signal Attributes library) to change type explicitly. Parameters: Output data type, Integer rounding mode (Floor, Ceiling, Nearest, Zero, Round, Convergent) and Saturate on integer overflow. Other relevant blocks:

  • Data Type Duplicate forces several signals to a common type.
  • Data Type Propagation copies a type from a reference signal.
  • The Fixed-Point Tool helps move a design from double to a deployed type.

Simulink never converts silently between some types (for example int8 and int16 into a Sum block with strict settings). When the types differ the diagnostic Data type conversion under Model Settings says whether to ignore, warn or error.

Overflow: wrap or saturate

Integer arithmetic has limited range. If uint8 250 plus 10 would exceed 255, either:

  • Wrap: the result is 260 mod 256 = 4; or
  • Saturate: the result sticks at the limit, 255.

The block parameter Saturate on integer overflow chooses. It is off by default for most math blocks (wrapping), which is what generated C code does for unsigned types. Saturation is usually safer for controllers, because a wrapped speed command could flip sign. The example below shows both.

Python Stand-in: integer wrap versus saturate (Python)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Wrapping int8 120 + 20 gives -116: a large positive value turns negative. This is why saturation matters for signed control signals.

Fixed-point numbers

Small processors lack a floating-point unit, so engineers store non-integer values as integers with an implied scale. fixdt(1, 16, 4) is a signed 16-bit number with 4 fractional bits: the stored integer q represents q / 2^4. The resolution is 2^-4 = 0.0625, the range is about -2048 to 2047.94. Values are quantized to multiples of the resolution.

Python Stand-in: fixdt(1,16,4) quantization (Python)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Note how 0.03 becomes 0.0 (smaller than half the resolution) and 2500 saturates. Choosing word and fraction lengths is a balance between range and precision; tools such as the Fixed-Point Tool and Fixed-Point Designer collect min/max data and propose types.

Common mistakes

Symptom Likely cause
"Dimension mismatch" error A Sum block gets [3] and [2]; or a matrix and a vector
Outputs jump to nonsense on a target Integer wrap-around of a signal
Values always zero after conversion Quantization: the value is smaller than the resolution
Different results from single and double Floating-point rounding; compare with a tolerance
"Data type mismatch" at a Switch The two data inputs have different types; add a Data Type Conversion

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does the label [3x1] on a line mean?

    The label shows signal dimensions: three rows, one column.
  2. 2. A uint8 signal holds 250 and 10 is added with wrap on overflow. What is the result?

    260 mod 256 = 4. With saturation the result would be 255.
  3. 3. What does fixdt(1,16,4) describe?

    Signed, word length 16, fraction length 4: resolution 1/16.
  4. 4. Which block explicitly changes a signal's data type?

    The Data Type Conversion block converts with chosen rounding and overflow behavior.

Summary

  • Every signal has a dimension, a data type and a sample time; display them with the information overlays.
  • Scalars are expanded to match vectors; matrix multiplication needs the right Gain setting.
  • Integer overflow wraps or saturates, depending on block settings; saturate for safety.
  • Fixed-point types trade range and resolution, quantizing values to multiples of 2^-f.

Next: Routing, Switches and Buses