getsignal

Value of signal

Description

example

signal_value = getsignal(target_object, signal_name) returns the value of signal signal_name at the time of the request. The value is not timestamped. Successive calls to this function do not necessarily return successive signal values.

example

signal_value = getsignal(target_object, signal_index) returns the value of the signal associated with signal_index at the time of the request. The value is not timestamped. Successive calls to this function do not necessarily return successive signal values.

Note

Signal access by signal index will be removed in a future release. Access signals by signal name instead.

example

signal_values = getsignal(target_object, signal_names) returns the values of signals identified in the cell array of character vectors signal_names at the time of the request. The values are not timestamped. Successive calls to this function do not necessarily return successive signal values.

Examples

collapse all

Get the value of signal 'Gain1'.

tg = slrt;
getsignal(tg, 'Gain1')
ans =  

-3.3869e+006

Get the signal index of signal 'Gain1', and then get its value.

tg = slrt;
sid = getsignalid(tg, 'Gain1');
getsignal(tg, sid)
ans =  

-3.3869e+006

Get the values of signals 'Sum' and 'Controller'.

tg = slrt;
getsignal(tg, {'Sum' 'Controller'})
ans =

     0     0

Input Arguments

collapse all

Object that represents the target computer. Before calling this function, make sure that you start the target computer with the Simulink® Real-Time™ kernel and apply the required Ethernet link settings.

Example: tg

The signal name refers to the block path of the block whose output is the specified signal. The software constructs the name according to these rules:

  • If the block has more than one output port, '/pn' is appended to the signal name. n is the port number (starting at 1).

  • If the output port is not a scalar, '/sn' is appended to the signal name. The number n is the index of signal signal_index within the vector or matrix. For this purpose, the signals are flattened to one dimension. For example, the signals /s1, /s2, /s3, and /s4 represent a 2 x 2 matrix.

For block subsystem/path/to/block, these rules result in the behavior listed in this table.

Output PortSignal Name
  • One output port.

  • The port is a scalar port.

subsystem/path/to/block

  • One output port.

  • The port is a vector port.

  • signal_index refers to the second element within that vector.

subsystem/path/to/block/s2

  • Three output ports.

  • The second port is a scalar port.

  • signal_index refers to the output from the second port.

subsystem/path/to/block/p2

  • Three output ports.

  • The second output port is a vector port.

  • signal_index refers to the seventh element within that vector.

subsystem/path/to/block/p2/s7

Index as shown in the Signals property of the real-time application. To be accessible via signal index, you must be able to observe the signal.

Note

Signal access by signal index will be removed in a future release. Access signals by signal name instead.

The cell array of character vectors or string array, signal_names, refers to the block paths of the blocks whose outputs are the specified signals. The software constructs the names according to the same rules as the signal_name argument.

Output Arguments

collapse all

Virtual and bus signals, optimized signals, and signals of complex data types are not observable.

Virtual and bus signals, optimized signals, and signals of complex data types are not observable.

Introduced in R2014a