| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
This class enables you to create workspace objects that you can use to assign or validate the attributes of a signal or discrete state, such as its data type, numeric type, dimensions, and so on. You can create a Simulink.Signal object in the MATLAB workspace or in a model workspace. If you create the object in a model workspace, you must set the object's storage class to Auto.
Objects of this class allow you to assign or validate signal or discrete state attributes by giving the signal or discrete state the same name as the workspace variable that references the Simulink.Signal object. For brevity, the rest of section refers only to specifying and validating signal attributes. The same techniques work with discrete states also.
You can use a variety of techniques to associate a signal object with a signal. For examples, see Using Signal Objects to Initialize Signals and Discrete States, Using Signal Objects to Tune Initial Values, and Applying CSCs to Parameters and Signals.
A given signal object can be associated with more than one signal only if the storage class of the signal object is Auto. If the object's storage class is other than Auto, it can be associated with at most one signal.
A given signal can be associated with at most one signal object under any circumstances. The signal can refer to the object more that once, but every reference must resolve to exactly the same object. A different signal object that has exactly the same properties will not meet the requirement for uniqueness.
A compile-time error occurs if a model associates more than one signal object with any signal. To prevent the error, decide which object the signal will use, then delete or reconfigure all references to any other signal objects, so that all remaining references resolve to the chosen signal object. See Displaying Signal Sources and Destinations for a description of techniques that you can use to trace the full extent of a signal.
You can use a signal object to assign values to signal attributes that are left unassigned (have a value of -1 or auto) by the signal source. To use a signal object to assign signal attribute values:
Create a Simulink.Signal object that has the same name as the signal.
Set the properties of the object that correspond to the attributes left unspecified by the signal source.
enable explicit or implicit signal resolution:
explicit resolution: In the signal's Signal Properties dialog box, enable Signal name must resolve to Simulink signal object. This is the preferred technique. See Explicit and Implicit Symbol Resolution for more information.
Implicit resolution: Set the model's Configuration Parameters > Diagnostics > Data Validity > Signal resolution option to explicit and implicit or explicit and warn implicit. The MathWorks recommends using explicit resolution only.
The signal object then provides the value of each signal attribute to which the signal source assigns a value of -1 or auto. (The same object could also validate any attribute to which the signal source assigns a specific value, rather than -1 or auto, as described in Using Signal Objects to Validate Signal Attributes.)
Using a Signal Specification Block
You can use a Signal Specification block rather than a Simulink.Signal object to assign properties left unspecified by a signal source. each technique has advantages and disadvantages:
Using a signal object simplifies the model and allows you to change signal property values without editing the model, but does not show signal property values directly in the block diagram.
Using a Signal Specification block displays signal property values directly in the block diagram, but complicates the model and requires editing it to change signal property values.
The following model illustrates the respective advantages of the two ways of assigning attributes to a signal.

In this example, the signal object named s1 specifies the sample time and data type of the signal emitted by input port In1 and a Signal Specification block specifies the sample time and data type of the signal emitted by input port In2. As this example illustrates, you have to display the signal object in the Model explorer to determine many of its properties whereas the Signal Specification block displays the property values on the diagram itself. On the other hand, using a signal object to specify the sample time and data type properties of signal s1 allows you to change the sample time or data type without having to edit the model. For example, you could use the Model explorer, the MATLAB command line, or an M-file program to change these properties.
You can use a signal object to validate signal attributes whose values are explicitly assigned by the signal source. Such attributes have values other than -1 or auto. Successful validation guarantees that the signal has the attributes that you intended it to have. To use a signal object to validate signal attributes:
Create a Simulink.Signal object that has the same name as the signal.
Set properties of the object to the values that corresponding signal attributes must have.
enable explicit or implicit signal resolution:
explicit resolution: In the signal's Signal Properties dialog box, enable Signal name must resolve to Simulink signal object. This is the preferred technique. See Explicit and Implicit Symbol Resolution for more information.
Implicit resolution: Set the model's Configuration Parameters > Diagnostics > Data Validity > Signal resolution option to explicit and implicit or explicit and warn implicit. The MathWorks recommends using explicit resolution only.
If the signal source assigns any value other than -1 or auto to a signal property, and the assigned value differs from the corresponding signal object value, the signal does not match the signal object and is therefore invalid. (The same object could also provide values for attributes that the signal source defines as -1 or auto, as described in Using Signal Objects to Assign Signal Attributes.)
The result when a signal does not match a signal object can depend on several factors. The Simulink engine can validate a signal property when you update the diagram, while you run a simulation, or both. When and how validation occurs can depend on internal rules that are subject to change, and sometimes on configuration parameter settings.
Not all signal validation compares signal source attributes with signal object properties. For example, if you specify Minimum and Maximum signal values using a signal object, the signal source must specify the same values as the signal object (or inherit the values from the object) but such validation relates only to agreement between the source and the object, not to enforcement of the Minimum and Maximum values during simulation.
If the value of Configuration Parameters > Diagnostics > Data Validity > Simulation range checking is none (the default) the Simulink engine does not enforce any signal's Minimum and Maximum values during simulation, even though a signal object provided or validated them. To enforce Minimum and Maximum signal values during simulation, you must set Simulation range checking to warning or error. See Checking Signal Ranges and Diagnostics Pane: Data Validity for more information.

Data type of the signal. The default entry, auto, specifies that Simulink software should determine the data type. Use the adjacent pulldown list to specify built-in data types (e.g., uint8). To specify a custom data type, enter a MATLAB expression that specifies the type, e.g., a base workspace variable that references a Simulink.NumericType object.
Click the Show data type assistant button
to display the Data
Type Assistant, which helps you set the Data
type parameter. (See Using the Data Type Assistant.)
Dimensions of this signal. Valid values are -1 (the default) specifying any dimensions, N specifying a vector signal of size N, or [M N] specifying an MxN matrix signal.
Numeric type of the signal. Valid values are auto (determined by Simulink software), real, or complex.
Rate at which the value of this signal should be computed. See How to Specify the Sample Time in the Simulink documentation for information on how to specify the sample time.
Sample mode of this signal. Simulink software ignores the setting of this field.
Minimum value that the signal should have. Specify a value that evaluates to a scalar, real number with double data type. Simulink software uses this value in the following ways:
When updating the diagram or starting a simulation, Simulink generates an error if the signal's initial value is less than the minimum value or if the minimum value is outside the range of the signal's data type.
When the Simulation range checking diagnostic is enabled, Simulink alerts you during simulation if the signal's value is less than the minimum value (see Simulation range checking).
Maximum value that the signal should have. Specify a value that evaluates to a scalar, real number with double data type. Simulink software uses this value in the following ways:
When updating the diagram or starting a simulation, Simulink generates an error if the signal's initial value is greater than the maximum value or if the maximum value is outside the range of the signal's data type.
When the Simulation range checking diagnostic is enabled, Simulink alerts you during simulation if the signal's value is greater than the maximum value (see Simulation range checking).
Signal or state value before a simulation takes its first time step. You can specify any MATLAB string expression that evaluates to a double numeric scalar value or array.
Valid:
1.5 [1 2 3] 1+0.5 foo = 1.5; s1.InitialValue = 'foo';
Invalid:
uint(1) foo = '1.5'; s1.InitialValue = 'foo';
If necessary, Simulink software converts the initial value to ensure type, complexity, and dimension consistency with the corresponding block parameter value. If you specify an invalid value or expression, an error message appears when you update the model. Also, Simulink performs range checking of the initial value. The software alerts you when the signal's initial value lies outside a range that corresponds to its specified minimum and maximum values and data type.
Initial value settings for signal objects that represent the following signals and states override the corresponding block parameter initial values if undefined (specified as []):
Output signals of conditionally executed subsystems and Merge blocks
Block states
Measurement units in which the value of this signal is expressed, e.g., inches. This field is intended for use in documenting this signal. Simulink software ignores it.
Storage class of this signal. See Tunable Parameter Storage Classes in the Real-Time Workshop User's Guide for more information .
Alternate name for this signal. Simulink software ignores this setting. This property is used for code generation.
Description of this signal. This field is intended for use in documenting this signal. This property is used by the Simulink Report Generator and for code generation.
Name | Access | Description |
|---|---|---|
Information used by Real-Time Workshop software for generating code for this signal. The value of this property is an object of Simulink.SignalRTWInfo class. | ||
Description | RW | Description of this signal. This field is intended for use in documenting this signal. (Description) |
String specifying the data type of this signal. (Data type) | ||
Minimum value that this signal can have. (Minimum) | ||
Maximum value that this signal can have. (Maximum) | ||
Measurement units in which this signal's value is expressed. (Units) | ||
Scalar or vector specifying the dimensions of this signal. (Dimensions) | ||
String specifying the numeric type of this signal. Valid values are 'auto', 'real', or 'complex'. (Complexity) | ||
Rate at which this signal should be updated. (Sample time) | ||
Sampling mode of this signal. (Sample mode) | ||
Signal or state value before a simulation takes its first time step. (Initial Value) |
![]() | Simulink.ScopeDataLogs | Simulink.SignalRTWInfo | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |