Products & Services Solutions Academia Support User Community Company

Learn more about Simulink   

Simulink.Signal - Specify attributes of signal

Description

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.

Multiple Signal Objects

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.

Using Signal Objects to Assign Signal Attributes

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:

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:

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.

Using Signal Objects to Validate Signal Attributes

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:

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.

Property Dialog Box

Data type

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

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.

Complexity

Numeric type of the signal. Valid values are auto (determined by Simulink software), real, or complex.

Sample time

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

Sample mode of this signal. Simulink software ignores the setting of this field.

Minimum

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

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).

Initial value

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

Units

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

Storage class of this signal. See Tunable Parameter Storage Classes in the Real-Time Workshop User's Guide for more information .

Alias

Alternate name for this signal. Simulink software ignores this setting. This property is used for code generation.

Description

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.

Properties

Name

Access

Description

RTWInfo

RW

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)

DataType

RW

String specifying the data type of this signal. (Data type)

Min

RW

Minimum value that this signal can have. (Minimum)

Max

RW

Maximum value that this signal can have. (Maximum)

DocUnits

RW

Measurement units in which this signal's value is expressed. (Units)

Dimensions

RW

Scalar or vector specifying the dimensions of this signal. (Dimensions)

Complexity

RW

String specifying the numeric type of this signal. Valid values are 'auto', 'real', or 'complex'. (Complexity)

SampleTime

RW

Rate at which this signal should be updated. (Sample time)

Sampling Mode

RW

Sampling mode of this signal. (Sample mode)

InitialValue

RW

Signal or state value before a simulation takes its first time step. (Initial Value)

  


Related Products & Applications

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