getsignalid

Signal index from signal hierarchical name

Description

example

signal_index = getsignalid(target_object, signal_name) returns the index of a signal from the signal list, based on the signal name. The signal name is derived from the path to the block.

Note

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

For signal_name, enter the mangled name that the Simulink® Coder™ software uses for code generation. To determine the mangled name:

  • If you do not have special characters in your model, use the gcb function.

  • If the blocks of interest have special characters, retrieve the mangled name by using tg.showsignals='on'.

    For example, if carriage return '\n' is part of the block path, the mangled name returns with carriage returns replaced by spaces.

Enter the complete names. The names are case sensitive.

Examples

collapse all

Get signal index for single output of block Gain1.

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

6

Get signal index for single output of block Feedback/Gain1.

tg = slrt;
getsignalid(tg, 'Feedback/Gain1')
ans = 

6

Get signal index of the second element of a wide output signal of block Byte Packing.

tg = slrt;
signal_index = getsignalid(tg,'Byte Packing /s2')
signal_index =

           1

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

Output Arguments

collapse all

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.

Introduced in R2014a