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:
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)
Many blocks can accept or output signals of any data or numeric type and dimensionality. Other blocks impose restrictions on the attributes of the signals that they can handle.
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).
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.
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 block from the Simulink Sources library into your model. For information about blocks that create signals in a model, see Sources .
You can use the Signal & Scope Manager to create signals in your model without using blocks. For more information, see Signal and Scope Manager .
A Simulink model can include many different types of signals. For details, see Signal Types. Different line styles help you to differentiate the signal types.
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. The only line style that you can customize is the nonscalar signal type. For information about this option, see Wide Nonscalar Lines.
|Signal Type||Line Style|
|Scalar and nonscalar|
|Nonscalar (with the Wide nonscalar lines option enabled—see Display Signal Attributes)|
|Array of buses|
Use the Property Inspector to specify properties for:
Signal names and labels
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. Select View > Property Inspector. When you select a signal, the properties appear in the Property Inspector. Alternatively, you can right-click a signal and select Properties to use the Signal Properties dialog box. For information about the benefits of each approach, see Setting Properties and Parameters.
To specify signal properties programmatically, use a function
get_param to get a handle to the block
output port that creates the signal line. Then, use
set the programmatic parameters of the port.
For an example, see Name a Signal Programmatically.
To learn how to map signal properties to programmatic port parameters, see Signal Properties Dialog Box Overview.
You can name a signal. By default, the signal name appears below a signal, displayed as a signal label. You can name a signal interactively in the model or by using the Signal Properties dialog box. You can also name the signal at the command prompt (see Name a Signal Programmatically). For a summary of how to work with signal names and labels in the Simulink Editor, see Signal Name and Label Actions.
The syntactic requirements for a signal name depend on how you use the name. The most common cases are:
The signal name can resolve to a
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
The signal has a name so the signal can be identified and referenced by name in a data log. (See Export 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 Handling 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
all input signal names, where
# is the input port
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
determine whether a signal name is a legal MATLAB identifier.
Displaying signal attributes in the model diagram can make the model easier to read. For example, in the Simulink Editor, use the Display > Signals & Ports menu to include in the model layout information about signal attributes, such as:
Port data types
For details, see Display Signal Attributes.
You can also highlight a signal and its source or destination blocks. For details, see Display Signal Sources and Destinations.
You can use block parameters to specify signal design attributes such as data type, minimum and maximum values, physical unit, and numeric complexity. You can also specify code generation settings by using signal properties, which you access through the Model Data Editor or signal properties dialog boxes. 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.
Choose which strategy to use based on your modeling goals.
To improve model portability, readability, and ease
of maintenance, store these specifications in the model file. You
do not need to save and manage external
Consider setting the model configuration parameter Signal
None, which disables
the use of
Simulink.Signal objects by the model.
To separate these specifications from the model so
that you can manage each independently, use
You can then configure the specifications in a flat list that you
can sort, group, and filter with the Model Explorer. To determine
where to permanently store the objects, see Determine Where to Store Variables and Objects for Simulink Models.
To configure design attributes and code generation settings
for root-level Inport and Outport blocks
by using a list that you can sort, group, and filter, consider the
Model Data Editor. You can also use the Model Data Editor to configure
code generation settings for internal signals. With this technique,
you store the specifications in the model file instead of using
See Configure Data Properties by Using a Table.
You can perform the following kinds of tests on signals:
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 Signal Ranges.
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 Builder block displays interchangeable groups of signal sources. Use the Signal Builder to create or edit groups of signals and to switch the groups into and out of a model.
Signal groups can help with testing a model, especially when you use them with Simulink Assertion blocks and the Model Coverage Tool in the Simulink Verification and Validation product.
For details, see Signal Groups.