Main Content


Read a signal value from a real-time application

Since R2021a



value = getsignal(target_object, blockPath, portIndex) returns the value of the signal selected by the portIndex in block block_path from the real-time application that is loaded on the target computer. This function also supports multi-instance referenced models.


collapse all

This example builds a real-time application from model slrt_ex_osc, loads the application on the target computer, and gets the value of the signal from block 'Signal Generator' port 1.

tg = slrealtime('TargetPC1');
getsignal(tg,'slrt_ex_osc/Signal Generator',1)
ans =


Input Arguments

collapse all

Provides access to methods that manipulate the target computer properties.

Example: tg

The block_path values can a character vector or string.

Example: 'slrt_ex_osc/Signal Generator'

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

Example: 1

Output Arguments

collapse all

The value is the value of the signal in the real-time application. If the signal is a bus, a struct is returned. Correct data type, complexity, and dimensions are returned.

Version History

Introduced in R2021a