Main Content

addSignal

Add signal for streaming to be available in callback

Description

example

addSignal(instrument_object,blockPath,portIndex,Name,Value) adds a signal by using the block path and the port index for streaming to make the signal available in a callback. Use this approach when you do not use the signal in a scalar displace or line plot.

example

addSignal(instrument_object,signalName,Name,Value) adds a signal by using the signal name for streaming to make the signal available in a callback. Use this approach when you do not use the signal in a scalar displace or line plot.

Examples

collapse all

Add a signal for streaming to the real-time instrument object by using the block path and port index.

mldatxfile = 'slrt_ex_tank.mldatx';
hInst = slrealtime.Instrument(mldatxfile);
addSignal(hInst,'slrt_ex_tank/ControlValue',1);

Add a signal for streaming to the real-time instrument object by using the signal name.

% added signal name to model before building mldatxfile
mldatxfile = 'slrt_ex_tank.mldatx';
hInst  = slrealtime.Instrument(mldatxfile);
addSignal(hInst,'ControlValueOut');

Input Arguments

collapse all

To create the instrument object, use the Instrument function.

Example: hInst

For the selected block, gcb returns the full block path name.

Example: slrt_ex_tank/ControlValue

For the selected signal, the output port index and signal name are visible in the signal hierarchy available in Simulink Real-Time explorer or in the Model Data Editor.

Example: 1

For the selected signal, the port index and signal name are visible in the signal hierarchy available in Simulink Real-Time explorer or in the Model Data Editor.

Example: ControlValueOut

The Name,Value pair argument selects the signal properties that are added to the instrument object instrument_object and sets values for the properties.

Example: 'Decimation',2

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Decimation',2

Specifies a particular element of a nonvirtual bus to stream. The syntax for the BusElement value:

  • Starts with the selected index for Array of Buses '(index).' or empty for scalar bus signals

  • Contains the path from the first level down to the leaf element

  • Separates each level of the hierarchy with a period '.'

  • Has a leaf as last level

  • Expresses the index for Array of Buses in the path as '(index)'

Example: 'BusElement','u1'

Example: 'BusElement','u4(1).b'

Example: 'BusElement','(1).a'

Specifies a decimation value for the signal.

Example: 'Decimation',2

Introduced in R2020b