Documentation

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

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

You can create a Simulink.Signal object in the MATLAB® workspace or in a model workspace.

Use signal objects 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 more information about using signal objects, see Use Simulink.Signal Objects to Specify and Control Signal Attributes and Data Objects.

Creation

Create a Simulink.Signal object:

Syntax

signalObj = Simulink.Signal

Description

signalObj = Simulink.Signal returns a Simulink.Signal object with default property values.

Properties

expand all

For information about properties in the property dialog box of a Simulink.Signal object, see Property Dialog Box.

Information used by Simulink® Coder™ for generating code for this signal. The value of this property is an object of Simulink.CoderInfo class.

For more information, see Storage Classes for Signals and States (Simulink Coder) and Simulink Package Custom Storage Classes (Embedded Coder).

Character vector specifying the numeric type of this signal. Valid values are 'auto' (determined by Simulink), 'real', or 'complex'.

Data Types: char

Character vector specifying the data type of this signal.

The default value, 'auto', specifies that Simulink should determine the data type. You can specify a built-in data type (for example, 'uint8' or 'single') or a custom data type. To specify a custom data type, use a MATLAB expression that specifies the type, (for example, the name of a Simulink.NumericType object that you create in the base workspace).

To specify a bus object as the data type for the signal object, use the 'Bus: <object_name>' syntax. See Bus Support for details about what you need to do if you specify a bus object as the data type.

Example: 'auto'

Example: 'int8'

Example: 'fixdt(1,16,5)'

Example: 'myAliasTypeObject'

Example: 'Enum: myEnumType'

Example: 'Bus: myBusObject'

Data Types: char

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.

If you have an Embedded Coder® license, you can add the signal description as a comment for the variable declaration in generated code:

  • Specify a storage class for the signal object other than Auto.

  • On the Code Generation > Comments pane of the model Configuration Parameters dialog box, select the model configuration parameter Simulink data object descriptions. For more information, see Simulink data object descriptions (Simulink Coder).

Example: 'This signal represents the rotation speed of the engine.'

Data Types: char

Scalar or vector specifying the 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.

To use symbolic dimensions, specify a character vector.

Example: [1 3]

Example: '[1 myDimParam]'

Data Types: double | char

Maximum value that this signal can have.

The default value is [] (unspecified). Specify a finite, real, double, scalar value.

Note

If you specify a bus object as the data type for a signal, do not set the maximum value for bus data on the signal property dialog box. Simulink ignores this setting. Instead, set the maximum values for bus elements of the bus object specified as the data type. For information on the Maximum property of a bus element, see Simulink.BusElement.

Simulink uses this value in the following ways:

  • When updating the diagram or starting a simulation, Simulink generates an error if the initial value of the signal is greater than the maximum value or if the maximum value is outside the range of the data type of the signal.

  • When you enable the Simulation range checking diagnostic, Simulink alerts you during simulation if the signal value is greater than the maximum value (see Simulation range checking).

Example: 5.32

Data Types: double

Minimum value that this signal can have.

The default value is [] (unspecified). Specify a finite, real, double, scalar value.

Note

If you specify a bus object as the data type for a signal, do not set the minimum value for bus data on the signal property dialog box. Simulink ignores this setting. Instead, set the minimum values for bus elements of the bus object specified as the data type. For information on the Minimum property of a bus element, see Simulink.BusElement.

Simulink 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 for the data type of the signal.

  • When you enable the Simulation range checking diagnostic, Simulink alerts you during simulation if the signal value is less than the minimum value (see Simulation range checking).

Example: -0.92

Data Types: double

Signal or state value before a simulation takes its first time step.

You can specify any MATLAB expression, including the name of a workspace variable, that evaluates to a numeric scalar value or array.

At the command prompt or in a script, even if you use a number, specify the initial value as a character vector.

mySigObject.InitialValue='5.3';
mySigObject.InitialValue = 'myNumericVariable';

To specify an initial value for a signal that uses a numeric data type other than double, cast the initial value to the signal data type. For example, you can specify 'single(73.3)' to use 73.3 as the initial value for a signal of data type single.

If you use a bus object as the data type for the signal object, set InitialValue to a character vector containing either 0 or a MATLAB structure that matches the bus object. See Bus Support for details.

If the initial value evaluates to a MATLAB structure, then in the Configuration Parameters dialog box, set Underspecified initialization detection to Simplified.

If necessary, Simulink 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 initial value of the signal lies outside a range that corresponds to its specified minimum and maximum values and data type.

Classic initialization mode: In this mode, 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

Simplified initialization mode: In this mode, initial values of signal objects associated with the following blocks are ignored. The initial values of the corresponding blocks are used instead.

  • Outport blocks of conditionally executed subsystems

  • Merge blocks

Example: '15.23'

Example: 'myInitParam'

Data Types: char

Rate at which this signal should be updated.

See Specify Sample Time for details.

Example: 0.001

Example: 2

Data Types: double

Physical unit used for expressing this signal value (for example, inches).

For more information, see Unit Specification in Simulink Models.

Example: 'degC'

Data Types: char

Examples

Simulink.Signal Examples

For examples that show how to use Simulink.Signal objects, see Use Simulink.Signal Objects to Specify and Control Signal Attributes and Data Objects.

Introduced before R2006a

Was this topic helpful?