Simulink.Signal - Specify attributes of signal

Description

This class enables you to create workspace objects that you can use to specify the attributes that a signal or discrete state should have, for example, its data type, numeric type, dimensions, and so on. You can create a Simulink.Signal object in the base MATLAB workspace or a model workspace. However, to create the object in a model workspace, you must set the object's storage class to Auto.

Objects of this class allow you to specify the 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. You can use signal objects both for specifying and checking signal properties.

Using Signal Objects to Specify Signal Properties

You can use signal objects to assign values to properties left unassigned by signal sources, i.e., that are assigned a value of -1 (inherited) or auto. To do this for a particular signal, create a signal object that has the same name as the signal and set the properties of the object that correspond to the properties left unspecified by the signal source.

You can also use a Signal Specification block to specify properties left unspecified by a signal source. The advantage of using signal objects is that it allows you to change signal property values without having to edit the model and it simplifies the model's diagram. The advantage of a Signal Specification block is that it displays the values assigned to the signal's properties on the block diagram itself.

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, the use of 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 Check Signal Properties

You can use signal objects to ensure that signal sources assign desired properties to a signal or state. This enables you to quickly determine whether the actual attributes of your model's signals are the attributes you intend them to have. To do this, create a Simulink.Signal object that has the same name as the signal or state to be validated and that specifies the desired properties. Then, whenever you update or run the diagram containing the signal or state, the Simulink engine checks the properties of the signal's or state's source against the properties specified by the Simulink.Signal object. If the source specifies a value other than inherited or auto for the properties, and the values specified by the source and the Simulink.Signal object differ, the Simulink engine displays an error message.

The engine checks the following properties whenever you update or run the diagram:

The engine checks the minimum and maximum values of the signal or state only when you run the simulation, not when the diagram is updated. In addition, to enable checking for the minimum and maximum values of a signal or state, you must set the Simulation range checking diagnostic on the Data Validity pane to either warning or error.

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 Specifying 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:

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:

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 []):

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

DataType

RW

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

Description

RW

Description of this signal. This field is intended for use in documenting this signal. (Description)

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)

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)

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.ParamRTWInfo class.

SampleTime

RW

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

Sampling Mode

RW

Sampling mode of this signal. (Sample mode)

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS