connectScalar
Syntax
Description
connectScalar(
connects a signal by using the block path and port index for streaming to a scalar display
as a scalar object.instrument_object
,hDisplay
,blockPath
,portIndex
,Name,Value
)
connectScalar(
connects a signal by using a signal name for streaming to a scalar display as a scalar
object.instrument_object
,hDisplay
,signalName
,Name,Value
)
Examples
Connect Signal by Using Block Path and Port Index
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 Signal by Using Signal Name
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
instrument_object
— Object that represents real-time instrument
object
To create the instrument object, use the Instrument
function.
Example: hInst
hDisplay
— Handle to a scalar display
object
The scalar display object displays the streaming data from the instrument in an edit box, gauge, or other display. object.
Example: myGauge
blockPath
— Block path for block with signal connected to one of its outports
character vector
For the selected block, gcb
returns the full block path name.
Example: slrt_ex_pendulum_100Hz/Pendulum
portIndex
— Index of block port that is connected to signal for streaming
integer
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
signalName
— Name of signal for streaming
character vector
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
Name,Value
— Pair that set properties values
name-value pair
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
ArrayIndex
— Array index of multi-element signal
integer
Selects an element of a multi-element signal.
Example: 'ArrayIndex',5
BusElement
— Nonvirtual bus element
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 signalsContains 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'
Callback
— Function handle
function handle
Provides function handle for accepting (time,data) arguments and returning data.
Example: 'Callback',
@(t,d)(d+app.Offset.Value)
Decimation
— Decimation value
1
(default) | 1 .. 256
Specifies a decimation value for the signal. Permitted values for decimation are from 1 to 256.
Example: 'Decimation',2
PropertyName
— Property to which values are streamed
Value
(default) | valid property name for selected component
Specifies a component property to which values are streamed. If
PropertyName
is not specified (default), the values are streamed
to the component Value
property.
Example: 'PropertyName', 'Color'
Version History
Introduced in R2020bR2022b: Select signals by name
In R2022b, you can use a signal name instead of a full block path to create robust
binding between a signal and an instrument. This support applies to the SignalTable
component and functions such as connectLine
or connectScalar
.
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)