Main Content

connectScalar

Add signal for streaming to scalar display

Since R2020b

Description

example

connectScalar(instrument_object,hDisplay,blockPath,portIndex,Name,Value) connects a signal by using the block path and port index for streaming to a scalar display as a scalar object.

example

connectScalar(instrument_object,hDisplay,signalName,Name,Value) connects a signal by using a signal name for streaming to a scalar display as a scalar object.

Examples

collapse all

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

mldatxfile = 'slrt_ex_pendulum_100Hz.mldatx';
hInst  = slrealtime.Instrument(mldatxfile);
connectScalar(hInst,myDisplay,'slrt_ex_pendulum_100Hz/cartposition',1);

Connect a signal for streaming to the real-time instrument object and display the object by using a signal name.

% added signal name to model before building mldatxfile
mldatxfile = 'slrt_ex_pendulum_100Hz.mldatx';
hInst  = slrealtime.Instrument(mldatxfile);
connectScalar(hInst,myDisplay,'cartposition');

Input Arguments

collapse all

To create the instrument object, use the Instrument function.

Example: hInst

The scalar display object displays the streaming data from the instrument in an edit box, gauge, or other display. object.

Example: myGauge

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

Example: slrt_ex_pendulum_100Hz/Pendulum

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: cartposition

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 pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'Decimation',2

Selects an element of a multi-element signal.

Example: 'ArrayIndex',5

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'

Provides function handle for accepting (time,data) arguments and returning data.

Example: 'Callback', @(t,d)(d+app.Offset.Value)

Specifies a decimation value for the signal. Permitted values for decimation are from 1 to 256.

Example: 'Decimation',2

Version History

Introduced in R2020b

expand all