## Signal Basics

A signal is a time-varying quantity that has values at all points in time. You can specify a wide range of signal attributes, including:

• Signal name

• Data type (for example, 8-bit, 16-bit, or 32-bit integer)

• Numeric type (real or complex)

• Dimensionality (one-dimensional, two-dimensional, or multidimensional array)

In Simulink®, signals are the outputs of dynamic systems represented by blocks in a Simulink diagram and by the diagram itself. The lines in a block diagram represent mathematical relationships among the signals defined by the block diagram. For example, a line connecting the output of block A to the input of block B indicates that the signal output of B depends on the signal output of A.

Simulink block diagrams represent signals with lines that have an arrowhead. The source of the signal corresponds to the block that writes to the signal during evaluation of its block methods (equations). The destinations of the signal are blocks that read the signal during the evaluation of the block methods (equations). The destination of signals in a model do not necessarily represent the order of simulation of blocks in a model. The simulation order is determined by Simulink automatically.

Note

Simulink signals are mathematical, not physical, entities. The lines in a block diagram represent mathematical, not physical, relationships among blocks. Simulink signals do not travel along the lines that connect blocks in the same way that electrical signals travel along a wire. Block diagrams do not represent physical connections between blocks.

You can create a signal by adding a source block to your model. For example, you can create a signal that varies sinusoidally with time by adding an instance of the Sine, Cosine block from the Simulink Sources library into your model. To see a list of the blocks that create signals in a model, see Sources. Alternatively, you can use the Viewers and Generators Manager to create signals in your model without using blocks.

### Signal Line Styles

A Simulink model can include many different types of signals. As you construct a block diagram, all signal types appear as a thin, solid line. After you update the diagram or start simulation, the signals appear with the specified line styles. These signal types enable you to differentiate between different signal types. From all signal types, you can only customize the nonscalar signal type. To learn more, see Signal Types.

Signal TypeLine Style
Scalar and nonscalar
Nonscalar (with the Wide nonscalar lines option enabled—see Wide Nonscalar Lines)

Control signal

Virtual bus
Nonvirtual bus
Array of buses
Variable-size

### Signal Properties

You may want to specify signal properties in your model to give a name or a label to your signals, prepare data for logging, or to customize your signals in a model. Use the Property Inspector, the Model Data Editor, or the Signal Properties dialog box to specify properties for:

• Signal names and labels

• Signal logging

• Simulink Coder™ to use to generate code

• Documentation of the signal

To access the signal properties in the Property Inspector, first display the Property Inspector. On the Modeling tab, under Design, click Property Inspector. When you select a signal, the properties appear in the Property Inspector.

To open the Model Data Editor, on the Modeling tab, click Model Data Editor. Then, inspect the Signals tab and select a signal.

To use the Signal Properties dialog box, right-click a signal and select Properties.

To specify signal properties programmatically, use a function such as `get_param` to create a variable that holds the handle to the block output port that creates the signal line. Then, use `set_param` to set the programmatic parameters of the port. For example:

```p = get_param(gcb,'PortHandles') l = get_param(p.Outport,'Line') set_param(l,'Name','s9')```

### Signal Names and Labels

You can name a signal interactively or programmatically in a model. The syntactic requirements for a signal name depend on how you use the name. The most common cases are:

• Do not use a less than character (`<`) to start a signal name.

• The signal name can resolve to a `Simulink.Signal` object. (See `Simulink.Signal`.) The signal name must then be a legal MATLAB® identifier. This identifier starts with an alphabetic character, followed by alphanumeric or underscore characters up to the length given by the function `namelengthmax`.

• The signal has a name so the signal can be identified and referenced by name in a data log. (See Save Signal Data Using Signal Logging.) Such a signal name can contain space and newline characters. These characters can improve readability but sometimes require special handling techniques, as described in Access Logged Signals with Spaces and Newlines in Logged Names

• The signal name exists only to clarify the diagram and has no computational significance. Such a signal name can contain anything and does not need special handling.

• The signal is an element of a bus object. Use a valid C language identifier for the signal name.

• Inputs to a Bus Creator block must have unique names. If there are duplicate names, the Bus Creator block appends `(signal#)` to all input signal names, where `#` is the input port index.

Making every signal name a legal MATLAB identifier handles a wide range of model configurations. Unexpected requirements can require changing signal names to follow a more restrictive syntax. You can use the function `isvarname` to determine whether a signal name is a legal MATLAB identifier.

Name a signal interactively by using one of these options:

The signal name appears below a signal, displayed as a signal label.

To name a signal programmatically, use the `get_param` and `set_param` functions on the signal. The table below summarizes how to work with signal names and labels in the Simulink Editor.

Name a signal lineDouble-click the signal and type its name.
Name a branch of a named signal lineDouble-click the branch.
Name every branch of a signal Right-click the signal, select Properties, and use the dialog box.
Delete signal label and nameDelete characters in the label or delete the name in Signal Properties dialog box.
Delete signal label only Right-click the label and select Delete Label.
Open signal label text box for editing

Double-click the signal line.

Click the label.

Select the signal line (not the label) and use F2.

On a Mac, select the signal line (not the label) and use control+return.

Move signal label Drag the label to a new location on the same signal line.
Copy signal labelCtrl+drag the signal label.
Change the label fontSelect the signal line (not the label), and then on the Format tab, click the button arrow, then click Fonts for Model.

### Signal Display Options

Displaying signal attributes in the model diagram can make the model easier to read. For example, in the Simulink Editor, on the Debug tab, use the Information Overlays menu to include in the model layout information about signal attributes, such as:

• Port data types

• Design ranges

• Signal dimensions

• Signal resolution

For details, see Display Signal Attributes.

You can also highlight a signal and its source or destination blocks. For details, see Highlight Signal Sources and Destinations.

### Store Design Attributes of Signals and States

You can use block parameters and signal properties to specify signal design attributes such as data type, minimum and maximum values, physical unit, and numeric complexity. To configure states, you can use block parameters. When you use these block parameters and signal properties, you store the specifications in the model file.

Alternatively, you can specify these attributes by using the properties of a `Simulink.Signal` or `Simulink.ValueType` object that you store in a workspace or data dictionary.

Choose which strategy to use based on your modeling goals.

Modeling GoalStrategy

Improve model portability, readability, and ease of maintenance

Store signal attribute specifications in the model file. You do not need to save and manage external objects. Consider setting the model configuration parameter Signal resolution to `None`, which disables the use of `Simulink.Signal` objects by the model.

Separate signal attribute specifications from the model so that you can manage each signal independently

Use `Simulink.Signal` objects.

Separate signal attribute specifications from the model so that you can reuse an application-specific set of attributes

Use `Simulink.Valuetype` objects.

To configure design attributes and code generation settings for signals by using a list that you can sort, group, and filter, consider using the Model Data Editor. For objects, you can also use the Model Explorer.

To determine where to permanently store a `Simulink.Signal` or `Simulink.ValueType` object, see Determine Where to Store Variables and Objects for Simulink Models.

### Test Signals

You can perform the following kinds of tests on signals:

• Minimum and Maximum Values — For many Simulink blocks, you can specify a range of valid values for the output signals. Simulink provides a diagnostic for detecting when blocks generate signals that exceed their specified ranges during simulation. For details, see Specify Signal Ranges.

• Connection Validation — Many Simulink blocks have limitations on the types of signals that they accept. Before simulating a model, Simulink checks all blocks to ensure that the blocks can accommodate the types of signals output by the ports to which the blocks connect and reports errors about incompatibilities. To detect signal compatibility errors before running a simulation, update the diagram.

The Signal Editor block displays interchangeable groups of scenarios. Use the Signal Editor to display, create, edit, and switch interchangeable scenarios.

Scenarios can help with testing a model.