Main Content

connectXYPlot

Connect X and Y signal structures to display on axes

Since R2024b

Description

connectXYPlot(instrument_object,hAxis,xSignal,ySignal,Name,Value) connects two signals by using the xSignal struct and ySignal struct to display as an XY plot on an axes. The axes for connectXYPlot cannot be bound to some other signal, for example bound to another XY Plot or bound as a Time Plot by using connectLine.

Specify the X and Y signals for connectXYPlot by using structures. The BlockPath and PortIndex struct fields are mandatory. The Callback, BusElement, and ArrayIndex struct fields are optional. For more information, see More About.

example

Examples

collapse all

Connect an X signal structure and Y signal structure to display as an XY plot on an axes object. This example applies optional line style, maximum points, and decimation.

mldatxfile = 'slrt_ex_pendulum_100Hz.mldatx';
hInst  = slrealtime.Instrument(mldatxfile);
xSig = struct('BlockPath', {'x'}, ...
              'PortIndex', {-1}, ...
              'Callback', @(t,d)d+2);
ySig = struct('BlockPath', {[mdl '/Bus Creator']}, ...
              'PortIndex', {1}, ...
              'ArrayIndex', {3}, ...
              'BusElement', {'signal2'}); 
connectXYPlot(hInst,myAxis,xSig,ySig, ...
              'LineStyle',ls, ...
              'MaxPoints',100, ...
              'Decimation', 5);

Input Arguments

collapse all

To create the instrument object, use the Instrument function.

Example: hInst

To create an axes object, use hAxis = gca or hAxis = axes ().

Example: myAxes

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

Example: slrt_ex_pendulum_100Hz/Pendulum

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

Example: slrt_ex_pendulum_100Hz/Pendulum

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

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

Example: 'Decimation',2

Select an slrealtime.instrument.LineStyle object that customizes the line appearance. For more information about object, see slrealtime.instrument.LineStyle.

Example: 'LineStyle', objectName

Maximum number of data points to plot, specified as an integer scalar. The default value of is empty, which means the chart plots all of the available data points provided by the xSignal and ySignal structures.

Example: 'MaxPoints',100

More About

collapse all

blockPath

The block path field (character vector) identifies the block with its signal connected to one of its outports. For the selected block, gcb returns the full block path name. For example:

'BlockPath', {[mdl '/Bus Creator']}

portIndex

The port index field integer() identifies the port of the block that is connected to its signal for streaming. 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. For example:

'PortIndex', {1}

ArrayIndex

The array index field (integer) of multi-element signal selects an element of a multi-element signal for streaming. For example:

'ArrayIndex',5

BusElement

The nonvirtual bus element field (signal name, character vector) 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)'

For example:

'BusElement','u1'
'BusElement','u4(1).b'
'BusElement','(1).a'

Callback

The function handle field (function handle) provides function handle for accepting (time,data) arguments and returning data. For example:

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

Version History

Introduced in R2024b